Hi Marius, Thanks for confirming some of my questions! Is there a book that you would recommend that explains how python deals with all this? I have read Apress' Beginning Python and I have read bits and pieces of the online python docs. I am willing to pick up other python books if there are some good ones.
Other comments inline: > From: Marius Gedminas > On Wed, Feb 28, 2007 at 11:47:15AM -0500, Giovannetti, Mark wrote: > > Hello, [snip] > > > > 1. At zope startup, each *-configure.zcml in etc/package-includes > > is read. > > Q. The __init__.py file for each package is then executed, correct? > > A. Yes, since my testing indicates this is the case. I had problems > > understanding this since the idiom is to just place a comment in > > the __init__ file and it seemed rather useless to a new user. > > The __init__.py file is executed when you import a package. That > happens as a side effect when ZCML directives refer to classes and > functions in packages. The purpose of a __init__.py is to > define names that could be imported, and not to run some > initialization code. > > 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? > > > 2. Each configure.zcml file in the package's root directory (the > > one pointed to by the *-configure.zcml in package-includes) is > > parsed. > > Q. Does each class referred to in a <class..> directive have > > the class' entire module loaded/executed or is the class just > > registered somewhere for future use? > > A. ? > > Yes, the module is imported. Thank you. > > > 3. Utilities and such in zcml. > > Q. Does each utility have its module executed to create the > > instance (utilities are instances, right?) > > A. I think so, but I'm not sure, see #2. > > Yes, the module is imported. > > > I hope someone can clear this up for me. I never managed to > > find a good explanation of the flow of control for zope3 > > startup and initialization. I have read both books already. > > In brief, Zope 3 reads the configuration file (zope.conf), > finds out the > name of the root zcml file (site.zcml, usually), then loads the ZCML > configuration (which involves parsing all the zcml files that include > each other, importing Python modules and accessing names defined in > those), executes the configuration (which involves modifying global > registries of adapters, utilities, security declarations > etc), opens or creates the ZODB database, and then starts > listening on network ports. > > Marius Gedminas I noticed that I could see this happening by watching the output of: # tail -F zope-instance/log/transcript.log if I add the following 'level debug' option to zope.conf (from a prior thread): <eventlog> # This sets up logging to both a file and to standard output # (STDOUT). The "path" setting can be a relative or absolute # filesystem path or the tokens STDOUT or STDERR. level debug <logfile> path $LOGDIR/z3.log formatter zope.exceptions.log.Formatter </logfile> <logfile> path STDOUT formatter zope.exceptions.log.Formatter </logfile> </eventlog> I can see all of the zcml files being called. Mark -- 613-947-1359 System Scientist / Scientifique, spécialiste des systèmes Canada Centre for Remote Sensing / Centre canadien de télédéction Natural Resources Canada, 588 Booth Street, Ottawa, Ontario, Canada, K1A 0Y7 Ressources naturelles Canada, 588 rue Booth, Ottawa, Ontario, Canada, K1A 0Y7 Government of Canada / Gouvernement du Canada _______________________________________________ Zope3-users mailing list Zope3firstname.lastname@example.org http://mail.zope.org/mailman/listinfo/zope3-users