[Zope3-Users] Re: register and unregister Utility
Stephan Richter
srichter at cosmos.phy.tufts.edu
Mon Jan 8 02:24:45 EST 2007
On Saturday 30 December 2006 13:26, Florian Lindner wrote:
> from zope import component
> components = component.registry.Components()
> components.registerUtility(self, INewsfeed, self.__name__)
>
> (example from registry.txt from apidoc)
>
> It works so far that no error is raised. But I wonder why the object is not
> shown as registered in the ZMI?
You register the newsfeed with the *global* components registry, not with the
local root components registry. This is the reason, you will not see it as
registered. Further, once you restart Zope, the regstration will be gone.
What you need:
root = getRootFolder()
sm = root.getSiteManager()
sm.registerUtility(self, INewsfeed, self.__name__)
Regards,
Stephan
--
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
More information about the Zope3-users
mailing list