[Zope-dev] zope.component.zcml and global registry

Roger dev at projekt01.ch
Wed Mar 3 07:22:25 EST 2010


Hi Fabio 

> Betreff: Re: [Zope-dev] zope.component.zcml and global registry
> 
> Hello roger,
> 
> * 2010-03-03 11:36, Roger wrote:
> > Not sure if I understand you correct. But what do you think 
> about the 
> > following:
> > 
> > - implement a new optional attribute useLocal=True
> >   in the directive and then configure the directive action
> >   and make use of the (local) getSiteManager method.
> > 
> > I like to use getGlobalSiteManager by default because this doesn't 
> > force a database access and load the local site manager if 
> the site is 
> > a local site.
> 
> I'm not sure what you mean with "doesn't force a database 
> access and load the local site manager". This is the 
> implementation of getSiteManager from
> zope.component._api:
> 
>     base = None
>     @hookable
>     def getSiteManager(context=None):
>         global base
>         if context is None:
>             if base is None:
>                 from zope.component.globalregistry import base
>             return base
>         else:
>             # Use the global site manager to adapt context to 
> `IComponentLookup`
>             # to avoid the recursion implied by using a local 
> `getAdapter()` call.
>             try:
>                 return IComponentLookup(context)
>             except TypeError, error:
>                 raise ComponentLookupError(*error.args)
> 
> In our use cases (ZCML registrations), context is None and 
> thus it will simply return the global registry, without any 
> database access. It is the equivalent of 
> getGlobalSiteManager, but it can be hooked (note the 
> @hookable decorator).
> 
> > Could this be an alternative concept and fit?
> 
> This would change the API, my proposed change is 
> back-compatible and does not introduce any new API (because 
> it is equivalent, indeed).

Uhh, I didn't understand your question correct.
I was thinking that the getGlobalSiteManager should
lookup the local registry. Sorry about that.

Regards
Roger Ineichen


> Best regards,
> Fabio
> 



More information about the Zope-Dev mailing list