[Zope3-Users] Registered utility is never found

FB fbo2 at gmx.net
Tue Dec 12 09:10:26 EST 2006


On Tue, Dec 12, 2006 at 04:42:56PM +0300, Garanin Michael wrote:
> FB wrote:
> >Hi,
> >
> >is there any reason why a registered utility which is persistently stored inside the site
> >manager is never found via zapi.getUtility(IMyInterface) ?
> >
> >More information:
> >
> >I wrote a package ( fb ) containing some components making the developer's life easier. The package
> >provides a class fb.init.indicator.InitIndicator. A application depending on the fb package is
> >supposed to make an instance of the InitIndicator, put it into the site manager and register it.
> >
> >As soon as the InitIndicator exists, the annoying "This site is not
> >initialized, yet"-message provided by the fb package's skin (which just
> >checks if "zapi.getUtility(IInitIndicator) is not None") disappears.
> >
> >  
> traceback, please.

Hmm ... how? It just doesn't return the utility as expected (it returns
None). There is no error shown in any way.

I used pdb to trace the problem down to zope.component.registry.queryUtility
. The call to self.utilities.lookup returns None but should return a
persistent instance of my InitIndicator class. The call to lookup() is
not tracable - I guess it's written C(|++) .

However - watch this:

> /ZOPE/zope3/src/zope/component/registry.py(132)queryUtility()
-> return self.utilities.lookup((), provided, name, default)
(Pdb) [reg for reg in self.registeredUtilities() if reg.provided is IInitIndicator]
[UtilityRegistration(<LocalSiteManager ++etc++site>, IInitIndicator, u'fb', initindicator, '')]
(Pdb) self.utilities.lookup((), provided, name, default)

(The initindicator utility is registered but lookup() can't find it.)

Regards,

Frank


More information about the Zope3-users mailing list