[Zope3-dev] How to Subscribe to Events?

Steve Alexander steve@cat-box.net
Sun, 04 May 2003 20:42:30 +0200


Marcus J. Ertl wrote:
> Hi!
> 
> How may I subscribe a placefull Object witch implements ISubscriber to
> a event?

If it is the kind of object that is meant to be added to a container, 
have it subscribe itself when it is added to the container by making it 
implement zope.app.interfaces.container.IAddNotifiable.

If you don't want to make your content class responsible for 
implementing IAddNotifiable, write it as an adapter from 
IYourContentType to IAddNotifiable.


> Doing it in configure.zcml is impossible for such cases!

Right.


> And where would be the right place to register it? In the objects
> __init__()?

No. It will not have access to any context at that point, so it won't be 
able to get at the event subscription service.

--
Steve Alexander