[Zope3-Users] Re: Next steps...
Philipp von Weitershausen
philipp at weitershausen.de
Mon Jul 24 03:13:21 EDT 2006
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",
>> 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.
More information about the Zope3-users