[Zope3-Users] Re: Zope3 startup

Philipp von Weitershausen philipp at weitershausen.de
Fri Mar 2 17:22:36 EST 2007


Marius Gedminas wrote:
> On Fri, Mar 02, 2007 at 12:31:22PM -0500, Giovannetti, Mark wrote:
>> Thanks for confirming some of my questions!  Is there a book
>> that you would recommend that explains how python deals with
>> all this?
> 
> I liked Mark Pilgrim's _Dive into Python_.  I don't remember if it goes
> into details about how Python modules work.
> 
>>> In fact, this is how Python imports modules: it executes the 
>>> .py file of the module.  (It does this at most once during the 
>>> program's execution, unless you explicitly ask it to reload 
>>> modules.  Zope 3 never asks.)
>> Great, now I think I have a good handle on what is going on.  This
>> also explains why I have to restart zope when I make code changes
>> (something that puzzled me very briefly when I started learning).
>>
>> So if I wanted to register utilities without using ZCML, I could
>> place the provideUtility(...) calls in an __init__.py or directly
>> within the utility's .py module.  Yes?
> 
> Yes, but only if you could make sure that your package or module was
> imported during Zope 3 startup.
> 
> Grok uses a similar scheme, as far as I understand: you declare your
> adapters and utilites in Python code, and then a single ZCML directive
> in the grok: namespace loads your package and registers everything.

Grok still makes a difference between *import time* and *configuration 
time*. I would not encourage doing component setup at import time. It 
doesn't play well with tests, for example, and it's hard to override 
(you have to do imports in the right order).

> Does Grok have a website?

Not yet. A prototype is at http://www.bud.ca/files/grokonepage/.


-- 
http://worldcookery.com -- Professional Zope documentation and training
Next Zope 3 training at Camp5: http://trizpug.org/boot-camp/camp5



More information about the Zope3-users mailing list