[Zope3-dev] Enabling services
Guido van Rossum
guido@python.org
Wed, 11 Dec 2002 13:08:43 -0500
> A recent update to SiteDefinition.py contains the following snippet
>
> sc = ServiceConfiguration('ObjectHub', here + ('ObjectHub-1',))
> configure.setObject(None, sc)
>
> # XXX I want to register and possibly activate these services,
> # but the following code doesn't work. :-(
> ##sc.status = "Active"
> # XXX And the following code doesn't work either. :-(
> registry = sm.createConfigurationsFor(sc)
> ##registry.register(sc)
> ##registry.activate(sc)
>
> sc needs to be context wrapped, e.g. by doing this
>
> key = configure.setObject(None, sc)
> sc = configure[key]
>
> Then
>
> sc.status = Active
>
> will work (import Active from Zope.App.OFS.Service.ConfigurationInterfaces).
>
> Hm...
>
> configure[configure.setObject(None, sc)].status = Active
>
> Maybe not. :-)
Thanks! That worked, after I context-wrapped everything else.
Do you happen to know if I can look up service factories by name?
--Guido van Rossum (home page: http://www.python.org/~guido/)