[Zope3-dev] event subscriptions, was re: ObjectHub Event names proposal

Gary Poster gary@modernsongs.com
Wed, 7 Aug 2002 00:08:00 -0400


"Florent Guillaume" <fg@nuxeo.com> wrote:
...

> If I'm subscribed to MoveEvent and AddEvent, and that MoveEvent
> inherits from AddEvent, and that a MoveEvent is generated, do I
> correctly get notified of the MoveEvent? Or the AddEvent? Or both?
> The most specific class makes more sense to me, but I had to ask...

I think your earlier question clarified that the interaction between the
various events, ObjectHub and not, needs to be thought about just a bit
more.  That said, given your question, there are two possible *theoretical*
situations.

If you had subscribed once for IObjectMovedEvent *and* once for
IObjectAddedEvent, and IObjectMovedEvent happened to subclass
IObjectAddedEvent, then when an ObjectMovedEvent instance was fired, your
subscriber would receive two calls to its notify method, once for each
subscription, both passing the original ObjectMovedEvent instance.

If you had subscribed once for IObjectAddedEvent (only), and
IObjectMovedEvent happened to subclass IObjectAddedEvent, then when an
ObjectMovedEvent instance was fired, your subscriber would receive one call
to its notify method, passing the original ObjectMovedEvent instance.

BTW, if for some reason you wanted to filter out IObjectMovedEvent-type
events in these theoretical scenarios, you could just add a filter to your
subscription.

Gary