Re: [Zope3-Users] Registered utility is never found
Hi, On Mon, Dec 11, 2006 at 12:58:21PM +0100, 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) ? It's strange - I installed the package on a different computer and wasn't able to reproduce the problem in any way. After I re-checked-out zope, my packages, some other stuff, recompiled, ... the problem was gone on the first computer, too. Thank you for all your help. I'll keep the list informed, if the problem re-occurs. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Registered utility is never found
Hi, On Wed, Dec 13, 2006 at 12:09:16PM +0300, Garanin Michael wrote: [snip] > Problem solved or no? If "no" then traceback please (after call > zapi.getUtility(IInitIndicator) ). It's working now. I'm doing some more tests because it was working yesterday for some minutes and somehow broke again (without a restart of zope!) or any change on the registration. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Registered utility is never found
FB wrote: Hi, On Tue, Dec 12, 2006 at 12:39:37PM -0500, Benji York wrote: Tom Gross wrote: you are trying to lookup the utility with the name None. If you don't specify a name when registering the utility, omit the second parameter: zapi.getUtility(IInitIndicator) In other words, the name of an unnamed utility isn't None, but the empty string. That's not the problem. I tried None (but forget to remove it later) because it wasn't working in the first place. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users Problem solved or no? If "no" then traceback please (after call zapi.getUtility(IInitIndicator) ). ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Registered utility is never found
Hi, On Tue, Dec 12, 2006 at 12:39:37PM -0500, Benji York wrote: > Tom Gross wrote: > >you are trying to lookup the utility with the name None. If you don't > > specify a name when registering the > >utility, > >omit the second parameter: zapi.getUtility(IInitIndicator) > > In other words, the name of an unnamed utility isn't None, but the empty > string. That's not the problem. I tried None (but forget to remove it later) because it wasn't working in the first place. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Registered utility is never found
Tom Gross wrote: you are trying to lookup the utility with the name None. If you don't specify a name when registering the utility, omit the second parameter: zapi.getUtility(IInitIndicator) In other words, the name of an unnamed utility isn't None, but the empty string. -- Benji York Senior Software Engineer Zope Corporation ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Registered utility is never found
Hi Frank, you are trying to lookup the utility with the name None. If you don't specify a name when registering the utility, omit the second parameter: zapi.getUtility(IInitIndicator) Cheers -Tom FB wrote: On Tue, Dec 12, 2006 at 05:29:55PM +0300, Garanin Michael wrote: FB wrote: On Tue, Dec 12, 2006 at 04:42:56PM +0300, Garanin Michael wrote: traceback, please. Hmm ... how? It just doesn't return the utility as expected (it returns None). There is no error shown in any way. >from APIDOC: """ * *|getUtility(interface, name='', context=None)| * . If one is not found, raises ComponentLookupError. < must be EXCEPTION !!! """ There are not "ComponenLookupError" exception? Why you find bug in "getUtility"? ;-) Sorry - my fault :-) I'm using queryUtility all the time. Here's the traceback: File "/var/lib/zope3/instance/lib/python/fb/init/tales.py", line 29, in warn indicator=zapi.getUtility(IInitIndicator,None) File "/ZOPE/zope3/src/zope/component/_api.py", line 207, in getUtility raise ComponentLookupError(interface, name) ComponentLookupError: (, None) Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Registered utility is never found
Hi, On Tue, Dec 12, 2006 at 04:14:31PM +0100, David Johnson wrote: > Try: > -- > utils = zapi.getAllUtilitiesRegisteredFor(IYourInterface) > for util in utils: > print util > -- > > You can list all the returned utilities. See if your utility is returned, and > see what name it is > registered under. If not, try with a known interface. Can you provide the > results here? That seems to be ok: (Pdb) zapi.getAllUtilitiesRegisteredFor(IInitIndicator) [, ] (Pdb) The first one was created by the -statement in zcml and should be superseded by the second one which is persistent in the site manager. Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Registered utility is never found
On Tue, Dec 12, 2006 at 05:29:55PM +0300, Garanin Michael wrote: > FB wrote: > >On Tue, Dec 12, 2006 at 04:42:56PM +0300, Garanin Michael wrote: > > > >>traceback, please. > >> > > > >Hmm ... how? It just doesn't return the utility as expected (it returns > >None). There is no error shown in any way. > > > > > > >from APIDOC: > """ > >* *|getUtility(interface, name='', context=None)| * > > . If one is not found, raises > ComponentLookupError. < must be EXCEPTION !!! > > > """ > > There are not "ComponenLookupError" exception? Why you find bug in > "getUtility"? ;-) Sorry - my fault :-) I'm using queryUtility all the time. Here's the traceback: File "/var/lib/zope3/instance/lib/python/fb/init/tales.py", line 29, in warn indicator=zapi.getUtility(IInitIndicator,None) File "/ZOPE/zope3/src/zope/component/_api.py", line 207, in getUtility raise ComponentLookupError(interface, name) ComponentLookupError: (, None) Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Registered utility is never found
Try: -- utils = zapi.getAllUtilitiesRegisteredFor(IYourInterface) for util in utils: print util -- You can list all the returned utilities. See if your utility is returned, and see what name it is registered under. If not, try with a known interface. Can you provide the results here? On Tue, 12 Dec 2006 15:29:55 +0100, Garanin Michael <[EMAIL PROTECTED]> wrote: FB wrote: On Tue, Dec 12, 2006 at 04:42:56PM +0300, Garanin Michael wrote: traceback, please. Hmm ... how? It just doesn't return the utility as expected (it returns None). There is no error shown in any way. from APIDOC: """ * *|getUtility(interface, name='', context=None)| * . If one is not found, raises ComponentLookupError. < must be EXCEPTION !!! """ There are not "ComponenLookupError" exception? Why you find bug in "getUtility"? ;-) (sorry my english) ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Registered utility is never found
FB wrote: On Tue, Dec 12, 2006 at 04:42:56PM +0300, Garanin Michael wrote: traceback, please. Hmm ... how? It just doesn't return the utility as expected (it returns None). There is no error shown in any way. from APIDOC: """ * *|getUtility(interface, name='', context=None)| * . If one is not found, raises ComponentLookupError. < must be EXCEPTION !!! """ There are not "ComponenLookupError" exception? Why you find bug in "getUtility"? ;-) (sorry my english) ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Registered utility is never found
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(, IInitIndicator, u'fb', initindicator, '')] (Pdb) self.utilities.lookup((), provided, name, default) (The initindicator utility is registered but lookup() can't find it.) Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Registered utility is never found
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. ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Registered utility is never found
Hi, On Tue, Dec 12, 2006 at 01:54:01PM +0100, Tom Gross wrote: > Hi Frank, > >is your InitIndicator-instance implementing the > IInitIndicatorFB-interface. This is absolutely > necessary > for providing it as an utility. There's an easy test for this: > > >>> from zope.interface.verify import verifyObject > >>> ii = InitIndicator() > >>> verifyObject(IInitIndicatorFB, ii) > True > > I usually put this in the docstring of classes I want to use as utilities. > Just to make sure :-). it verifies successfully. This is the *whole* class ... class InitIndicator(Contained,Persistent): implements(IInitIndicator) def __init__(self,application='',url='',description=u''): self.application=application self.url=url self.description=description ... this is the interface ... class IInitIndicator(Interface): """A utility that is registered, when a application is initialized""" application=BytesLine( title=_(u"Application id"), description=_(u"Python package of the application which initialized the site"), required=False ) url=URI( title=_(u"Homepage"), description=_(u"Homepage of the initializing application"), required=False, ) description=TextLine( title=_(u"Short description"), description=_(u"Short textual description of the application"), default=u"" ) ... and this is all zcml related to this class: Yet, that's *really* the whole thing. There are some more browser-related zcml-statements which I added when I realized that it just didn't work :-( . Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Registered utility is never found
Hi Frank, is your InitIndicator-instance implementing the IInitIndicatorFB-interface. This is absolutely necessary for providing it as an utility. There's an easy test for this: >>> from zope.interface.verify import verifyObject >>> ii = InitIndicator() >>> verifyObject(IInitIndicatorFB, ii) True I usually put this in the docstring of classes I want to use as utilities. Just to make sure :-). -Tom wrote: Hi, On Tue, Dec 12, 2006 at 07:56:53AM +1100, Tom Dossis 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. But: It *doesn't work* and a don't have the slightest clue why. This is, what my application's initialisation routine does: def initApplication(root): sm=getSiteManager() df=sm['default'] initindicator=InitIndicator('mpgsite','http://zope3.mpg.de/topic/MpgSite',u"no info") df['initindicator']=initindicator sm.registerUtility(df['initindicator'],IInitIndicator,'','') [...] test=zapi.getUtility(IInitIndicator) # Works! [...] Querying the IInitIndicator component works directly after the registration but *nowhere* else in my application. Have you 'browsed' the utility via the ZMI 'Manage Site'? Is there an instance there (in the site you expect it to be)? If so the 'Registration' page could provide some useful info. Yes. The instance is there, the registration tab shows the registration as expected, the site root folder itself lists the registration in site.registrations lists the registration as expected. Registering via browser doesn't work either :-( . BTW: I've got dozens of other utilities registered that are working perfectly. Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Registered utility is never found
Hi, On Tue, Dec 12, 2006 at 07:56:53AM +1100, Tom Dossis 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. > > > > But: It *doesn't work* and a don't have the slightest clue why. This is, > > what my application's initialisation routine does: > > > > > > def initApplication(root): > >sm=getSiteManager() > >df=sm['default'] > > > > initindicator=InitIndicator('mpgsite','http://zope3.mpg.de/topic/MpgSite',u"no > > info") > >df['initindicator']=initindicator > >sm.registerUtility(df['initindicator'],IInitIndicator,'','') > >[...] > >test=zapi.getUtility(IInitIndicator) # Works! > >[...] > > > > Querying the IInitIndicator component works directly after the registration > > but *nowhere* else in my application. > > > > > Have you 'browsed' the utility via the ZMI 'Manage Site'? > Is there an instance there (in the site you expect it to be)? > If so the 'Registration' page could provide some useful info. Yes. The instance is there, the registration tab shows the registration as expected, the site root folder itself lists the registration in site.registrations lists the registration as expected. Registering via browser doesn't work either :-( . BTW: I've got dozens of other utilities registered that are working perfectly. Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Registered utility is never found
Hi, On Mon, Dec 11, 2006 at 11:41:25PM +0100, David Johnson 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) ? > It's been my experience this is caused by registering with a name rather than > leaving the registration > blank. (This confused me for the longest time). As shown in the sample code, the registration is done with name='' . Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Registered utility is never found
Hi, is there any reason why a registered utility which is persistently stored inside the site manager is never found via zapi.getUtility(IMyInterface) ? It's been my experience this is caused by registering with a name rather than leaving the registration blank. (This confused me for the longest time). ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Registered utility is never found
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. > > But: It *doesn't work* and a don't have the slightest clue why. This is, > what my application's initialisation routine does: > > > def initApplication(root): >sm=getSiteManager() >df=sm['default'] > > initindicator=InitIndicator('mpgsite','http://zope3.mpg.de/topic/MpgSite',u"no > info") >df['initindicator']=initindicator >sm.registerUtility(df['initindicator'],IInitIndicator,'','') >[...] >test=zapi.getUtility(IInitIndicator) # Works! >[...] > > Querying the IInitIndicator component works directly after the registration > but *nowhere* else in my application. > Have you 'browsed' the utility via the ZMI 'Manage Site'? Is there an instance there (in the site you expect it to be)? If so the 'Registration' page could provide some useful info. Regards, -Tom ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Registered utility is never found
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. But: It *doesn't work* and a don't have the slightest clue why. This is, what my application's initialisation routine does: def initApplication(root): sm=getSiteManager() df=sm['default'] initindicator=InitIndicator('mpgsite','http://zope3.mpg.de/topic/MpgSite',u"no info") df['initindicator']=initindicator sm.registerUtility(df['initindicator'],IInitIndicator,'','') [...] test=zapi.getUtility(IInitIndicator) # Works! [...] Querying the IInitIndicator component works directly after the registration but *nowhere* else in my application. Doesn anyone have an idea, what can cause such an error? Regards, Frank ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users