Re: [Zope3-Users] Re: register and unregister Utility

2007-01-08 Thread Stephan Richter
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
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: register and unregister Utility

2006-12-30 Thread Florian Lindner
Am Mittwoch, 27. Dezember 2006 21:42 schrieb Jürgen Kartnaller:
> Florian Lindner wrote:
> > Am Mittwoch, 27. Dezember 2006 19:15 schrieb Jürgen Kartnaller:
> >> component.provideUtility for a global utility.
> >
> > I've found that.
> >
> >> See zope.component.interfaces.IComponentRegistrationConvenience
> >
> > Ok, for registering. But what to call for unregistering? (I have a global
> > utility)
>
> zope.component.getGlobalRegistry() implements IComponentRegistry
>
> >> Or for local utilities registered in a site manager you use the site
> >> manager :
> >>
> >> sm.registerUtility
> >> sm.unregisterUtility
> >>
> >> See zope.component.interfaces.IComponentRegistry
> >
> > Ok, there is the unregisterUtility function. Where do I get an object
> > implementing this interface?

I have done it this way now:

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?

Thanks,

Florian
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: register and unregister Utility

2006-12-27 Thread Florian Lindner
Am Mittwoch, 27. Dezember 2006 19:15 schrieb Jürgen Kartnaller:
> component.provideUtility for a global utility.

I've found that.

> See zope.component.interfaces.IComponentRegistrationConvenience

Ok, for registering. But what to call for unregistering? (I have a global 
utility)

> Or for local utilities registered in a site manager you use the site
> manager :
>
> sm.registerUtility
> sm.unregisterUtility
>
> See zope.component.interfaces.IComponentRegistry

Ok, there is the unregisterUtility function. Where do I get an object 
implementing this interface?

Thanks,

Florian

> Jürgen
>
> Florian Lindner wrote:
> > Hello,
> > easy question but I just don't finde the approbiate function. How to
> > register and unregister programmatically an utility?
> >
> > Thanks,
> >
> > Florian
>
> ___
> Zope3-users mailing list
> Zope3-users@zope.org
> http://mail.zope.org/mailman/listinfo/zope3-users
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users