[Zope3-Users] Re: Next steps...

2006-07-24 Thread Philipp von Weitershausen
Tim Penhey wrote:
 On Friday 21 July 2006 16:24, Tim Penhey wrote:
 Hi All,

 Going through Philipp's book some more...

 Once the sections get to content types the samples always show:
  from zope.app.debug import Debugger
  debugger = Debugger(db=var/Data.fs,
   config_file=etc/site.zcml)

 The purpose for this doesn't seem to be described anywhere.  I can guess, 
 but 
 I am curious to the actual reason.  Is it just to initalise the zope 
 environment, set the persistant store and config?

The Debugger will load ZCML configuration and set up a database, as you
guessed correctly. The interpreter examples that use the debugger (many
of them do, but not all) really only need its configuration
functionality; every time an interpreter session needs ZCML
configuration loaded, the debugger is used.

Note that in newer Zopes we have a debug shell which saves you a lot of
typing. Simply execute bin/zopectl debug from your instance (you don't
even have to put $INSTANCE/lib/python on your PYTHONPATH), the effect is
the same as the Debugger stanza you see in my book. zopectl debug wasn't
around when I wrote the first edition, unfortunately.

 Given that I am writing my code somewhere different than my zope instance,
 how to I extend the default site.zcml to include my stuff?
 
 I'm sure that the debugger does much more, but after a few minutes thinking 
 about how to add things it seemed relatively obvious - just not explicitly 
 described anywhere.
 
 For the benefit of others:
   - put your development directory in your PYTHONPATH
   - add a include package=xxx/ in the site.zcml for your package.

Indeed that's what you have to do (instead of editing site.zcml you can
also put a worldcookery-configure.zcml slug into etc/package-includes).
This is, btw, described in Chapter 2 as a necessary step for making the
examples work anyway (especially the interactive interpreter sessions).

 In chapter 5 (Content Components), the Recipe object ends up using
 FieldProperty to initialise members based on the interfaces schema, however
 in chapter 6 (Persistency) these are dropped and empty unicode strings and
 PersistentLists used instead.  Does this mean that you loose the schema
 checks on assignment now?  Confused :???:

Yes, you lose schema checks on assignment. Usually you don't care about
them, though. Automated add and edit forms will perform those checks on
the user input anyways, having them on the Python level is (almost) useless.

Philipp

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: Next steps...

2006-07-24 Thread Tim Penhey
On 7/24/06, Philipp von Weitershausen [EMAIL PROTECTED] wrote:
Note that in newer Zopes we have a debug shell which saves you a lot oftyping. Simply execute bin/zopectl debug from your instance (you don'teven have to put $INSTANCE/lib/python on your PYTHONPATH), the effect is
the same as the Debugger stanza you see in my book. zopectl debug wasn'taround when I wrote the first edition, unfortunately.Does this mean that a second edition is in the works? 
 Given that I am writing my code somewhere different than my zope instance, how to I extend the default 
site.zcml to include my stuff? I'm sure that the debugger does much more, but after a few minutes thinking about how to add things it seemed relatively obvious - just not explicitly described anywhere.
 For the benefit of others: - put your development directory in your PYTHONPATH - add a include package=xxx/ in the site.zcml for your package.Indeed that's what you have to do (instead of editing 
site.zcml you canalso put a worldcookery-configure.zcml slug into etc/package-includes).This is, btw, described in Chapter 2 as a necessary step for making theexamples work anyway (especially the interactive interpreter sessions).
Sorry, missed the bit in chapter 2 about this, or had just forgotten by the time I needed to do it.Is adding the slug to the etc/package-includes the preferred way of extending then? 
 In chapter 5 (Content Components), the Recipe object ends up using FieldProperty to initialise members based on the interfaces schema, however
 in chapter 6 (Persistency) these are dropped and empty unicode strings and PersistentLists used instead.Does this mean that you loose the schema checks on assignment now?Confused :???:
Yes, you lose schema checks on assignment. Usually you don't care aboutthem, though. Automated add and edit forms will perform those checks onthe user input anyways, having them on the Python level is (almost) useless.
PhilippOK, thanks. It is excellent to have the author answer the questions :)Tim 
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: Next steps...

2006-07-24 Thread Philipp von Weitershausen
Tim Penhey wrote:
 On 7/24/06, *Philipp von Weitershausen* [EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED] wrote:
 
 Note that in newer Zopes we have a debug shell which saves you a lot of
 typing. Simply execute bin/zopectl debug from your instance (you don't
 even have to put $INSTANCE/lib/python on your PYTHONPATH), the
 effect is
 the same as the Debugger stanza you see in my book. zopectl debug wasn't
 around when I wrote the first edition, unfortunately.
 
 Does this mean that a second edition is in the works?

Yup.

  Given that I am writing my code somewhere different than my zope
 instance,
  how to I extend the default site.zcml to include my stuff?
 
  I'm sure that the debugger does much more, but after a few minutes
 thinking
  about how to add things it seemed relatively obvious - just not
 explicitly
  described anywhere.
 
  For the benefit of others:
- put your development directory in your PYTHONPATH
- add a include package=xxx/ in the site.zcml for your
 package.
 
 Indeed that's what you have to do (instead of editing site.zcml you can
 also put a worldcookery-configure.zcml slug into etc/package-includes).
 This is, btw, described in Chapter 2 as a necessary step for making the
 examples work anyway (especially the interactive interpreter sessions). 
 
 
 Sorry, missed the bit in chapter 2 about this, or had just forgotten by
 the time I needed to do it.
 
 Is adding the slug to the etc/package-includes the preferred way of
 extending then?

I wouldn't say that. It depends on your taste, really. I personally
prefer the package-includes approach for development environments; for
actual deployments I find having no package-includes at all, but instead
putting everything in site.zcml useful, because it's easier to see in
one place what's included and what not.

Philipp
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Re: Zope 3 rdb adapter on Zope 2 - a good idea?

2006-07-24 Thread Anton Stonor

Anton Stonor wrote:

What rdb adapter should I use on Zope 2: Zope 2 or Zope 3?


Well, now I've done some research to answer my own question.

It looks like you can safely use the Zope 3 Mysql adapter on Zope 2.

Performance: Identical. A few, simple Apache Benchmark tests with SQL 
INSERTs and SELECTs shows almost identical req/second for Zope 2 and 
Zope 3 adapters.


Transactions: Works fine with the Zope 3 adapter. I made my view class 
break after an SQL-insert and the insert was rolled back.


Threads: Seems to instanciate one connection pr. thread as expected.


/Anton

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Re: Next steps...

2006-07-24 Thread Philipp von Weitershausen
Achim Domma wrote:
 Philipp von Weitershausen wrote:
 Tim Penhey wrote:
 Does this mean that a second edition is in the works?
 Yup.
 
 Nice to hear! The first edition helped me a lot. Is there already a time
 frame when it will be available?

No, I don't know how long it will take me and/or the publisher to get
everything done. I hope/expect by the end of this year, but I make no
promises.

 And is there a wish list for topics I want to see? ;-)

I don't understand this sentence.

Like the 1st edition covers everything you needed to know about Zope X3
3.0, the 2nd edition will do the same for Zope 3.3. That, of course,
includes new things.

Philipp

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Adapters and getters and setters

2006-07-24 Thread Darryl Cousins
Hi All,

I only recently began using formlib and I have used a schema to describe
the form, and provided an adapter to adapt the object to the schema.

It seems that formlib uses the adapter to access and set attributes on
the object. To allow it to do that I need to provide getters and setters
for the adapter to access the attributes on the object itself:

 class MyAdapterForMyObject(object):
... implements(IMyAdapter)
... def __init__(self, context):
... self.context = context
... def title():
... def fget(self):
... return self.context.title
... def fset(self, value):
... self.context.title = value
... return locals()
... title = property(**title())

Before using formlib I would usually have a getContext() method on the
adapter to return the adapted object and manually get or set the
attributes (in the update method for example). Doing the above means I
don't need to.

Am I going about this the right way?

Best regards,
Darryl Cousins

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Debugging Zope3 with Winpdb

2006-07-24 Thread Takayuki Shimizukawa

Hi Achim,

2006/7/23, Achim Domma [EMAIL PROTECTED]:

I try to debug zope 3 with winpdb, but without success. Was anybody able
to let zope 3 run within winpdb. Winpdb seems to start my z3.py script
but the looses the connection to the process. I see no error messages
and I'm quite new to winpdb.

Any help would be very appreciated!


I'm using winpdb on Windows.

- python-2.4.2.msi
- winpdb-1.0.6.tar.gz
- wxPython2.6-win32-unicode-2.6.3.2-py24.exe
- Zope-3.2.1

And I modified runzope.bat little.

before::
%PYTHON% %INSTANCE_HOME%\bin\runzope %1 %2 %3 %4 %5 %6 %7

after::
%PYTHON% \Python24\Scripts\_winpdb.py
%INSTANCE_HOME%\bin\runzope %1 %2 %3 %4 %5 %6 %7

--
Shimizukawa
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users