[Zope3-Users] Registered utility is never found

Tom Gross tom at lalisio.com
Tue Dec 12 07:54:01 EST 2006


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 at zope.org
> http://mail.zope.org/mailman/listinfo/zope3-users
>   



More information about the Zope3-users mailing list