[Zope3-Users] Trouble understanding events, handlers, subscribers
(Trying to use component architecture outside of Zope)
Dominik Huber
dominik.huber at perse.ch
Mon Jan 23 16:06:54 EST 2006
Jeff Shell wrote:
>I'm writing a small command line tool that uses parts of Zope 3's
>component architecture (zope.component, zope.interface, zope.schema),
>and just includes those packages and a couple of supporting ones found
>in dependencies (zope.i18nmessageid, exceptions, texting). No
>zope.app, publisher, server, etc. And (at present) no C code, so no
>zope.hookable either. And no ZCML.
>
>I'd like to use events in my tool, but I'm confused. I'm having a hard
>time understanding the terminology in zope.component / zope.interface
>regarding Subscribers and Handlers. I don't know if those are wired to
>zope.event.notify at all.
>
>
Nope, you have to register a dispatcher first that invokes the
subscribers registered within the adapter-registry.
See zope.app.event.dispatching
>I don't know how to translate something like:
>
><subscriber for="myapp.interfaces.IBeforeInstallEvent"
> handler="myapp.foo.ensurePaths"/>
>
>into zope.component.provide... provideHandler? provideSubscriber?
>
>
from zope.component import getGlobalSiteManager
gsm = getGlobalSiteManager()
gsm.subscribe(required, provided, factory)
the zcml example above:
gsm.subscribe((IBeforeInstallEvent,), None, ensurePaths)
>I think I'm just not understanding the relationship of 'for' (in the
>ZCML) to the provideHandler / provideSubscriber concepts of 'adapts'
>and 'provides', and what that means for me looking to subscribe to an
>event with a plain old function. Or class. Or instance.
>
>
A callable that takes one or more arguments corresponding to the number
of required interfaces.
Regards,
Dominik
More information about the Zope3-users
mailing list