[Zope3-Users] Registered utility is never found

Tom Gross tom at lalisio.com
Tue Dec 12 11:37:26 EST 2006


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: (<InterfaceClass fb.init.interfaces.IInitIndicator>, None)
>
> Regards,
>
> 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