[Zope3-Users] very simple problem with getUtility
Christian Theune
ct at gocept.com
Mon Jan 8 05:34:51 EST 2007
Hi,
Hi,
Christophe Combelles wrote:
> Hi
>
> There is probably something that I don't understand with registration. I'm doing
> the very simple thing:
>
> - 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:
>
>
> >>> from zope.component import getUtility
> >>> from zope.app.folder.interfaces import IFolder
> >>> getUtility(IFolder, 'foo')
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> File "/usr/lib/python2.4/site-packages/zope/component/_api.py", line 207, in
> getUtility
> raise ComponentLookupError(interface, name)
> zope.component.interfaces.ComponentLookupError: (<InterfaceClass
> zope.app.folder.interfaces.IFolder>, 'foo')
>
>
> What am I missing?
You're missing to set the local site manager for your thread:
>>> from zope.app.component.hooks import setSite
>>> setSite(root)
Christian
--
gocept gmbh & co. kg - forsterstraße 29 - 06112 halle/saale - germany
www.gocept.com - ct at gocept.com - phone +49 345 122 9889 7 -
fax +49 345 122 9889 1 - zope and plone consulting and development
More information about the Zope3-users
mailing list