Stephan Richter a écrit :
On Sunday 07 January 2007 08:17, Christophe Combelles wrote:
- I start zope with an empty zodb
- I add a Folder
- I go to the registration tab and register it for IFolder as 'foo'
- I stop zope, and start debugzope:

These steps are okay.

 >>> from zope.component import getUtility
 >>> from import IFolder
 >>> getUtility(IFolder, 'foo')
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
   File "/usr/lib/python2.4/site-packages/zope/component/", line
207, in getUtility
     raise ComponentLookupError(interface, name)
zope.component.interfaces.ComponentLookupError: (<InterfaceClass>, 'foo')

The registration is done locally. You have to set the site first or pass it as the context.

Yes, of course. Thanks. I forgot the context. I'm tired today.

So the correct session is:

>>> from import IFolder
>>> from zope.component import getUtility
>>> getUtility(IFolder, 'foo', root)
< object at 0xb6c68b2c>

But what did you mean as "set the site"?
do you mean with hooks.setSite() ?


Zope3-users mailing list

Reply via email to