[Zope3-dev] Re: zope.app.twisted.main?

Philipp von Weitershausen philipp at weitershausen.de
Tue Feb 6 10:21:35 EST 2007


On 6 Feb 2007, at 15:41 , Chris Withers wrote:
> Philipp von Weitershausen wrote:
>>> Why would this be in zope.conf at all?
>>> I would have thought just having a normal zcml setup for a  
>>> single, global IRootObjectFactory utility would be fine...
>> Well, actually, you can't register it through ZCML because ZCML  
>> knows nothing about the ZODB.
>
> Okay, how about the config parser registers the utility:

The config parser (ZConfig) is generic and doesn't know anything  
about the component architecture. The main() program in  
zope.app.appsetup, which makes use of the zope.conf configuration,  
would have to do it.

> from zope.component import provideUtility
> provideUtility(IRootObject,MyZODBRootThingy)
>
> Of course, I don't see any reason for the config parser to _have_  
> to do so... something just needs to register an IRootObject before  
> the first publication gets instantiated, right?

Right, but the whole point of factoring it out to a utility is to  
gain the ability to override things. If it's registered using  
z.c.provideUtility(), it'll be hard to impossible to override it  
using overrides.zcml. That's why I suggested we use named utilities  
because the we don't need to work with overrides.zcml.

> If so, what bad things could happen if the zodb sections in  
> zope.conf were made optional and a later zcml statement provided  
> the utility?
>
> <utility factory="myIRootObjectProvider" />

Yeah, but how would you implement myIRootObjectProvider w/o having  
access to the ZODB? You don't know which ZODB you're going to get the  
root object from because that's decided *at runtime* in the main()  
program by reading zope.conf.

>>> Also, why the factory? Why not just IRootObject?
>> I guess just IRootObject is ok, the factory would have been a bit  
>> more generic because then you're not registering a specific root  
>> object for all times but could actually incorporate some logic  
>> into the root-object-finding-process.
>
> Why would you want to do that?

Because I'm not sure how persistent objects behave in a global  
registry. Right now in the Zope default publication, the root object  
is gotten *after* opening the DB.  If we'd register the (persistent)  
root object in the global registry, it might exist w/o any ZODB  
connections open. Not sure if that's every going to occur, or if  
that's going to be a problem, etc.

Anyway, I think I've tried to give as many pointers as I could. I'm  
sure some of the things discussed here will come up when you'll  
implement this :).



More information about the Zope3-dev mailing list