[Zope3-dev] Event service should adapt to ISubscriber
Gary Poster
gary@modernsongs.com
Thu, 23 Jan 2003 22:10:22 -0500
Florent Guillaume wrote:
> In article <3E304589.7080601@cat-box.net> you write:
>
>>I'd also like to make ISubscribingAware something that can be adapted
>>to, rather than the current situation where it has to be implemented by
>>the object being subscribed to an event service.
>
>
> I don't understand that area all that well, but isn't it the same
> pattern than the one we're having with IAnnotations and IAnnotatable ?
>
> An object that is IAnnotatable promises that there is an adapter
> adapting it to IAnnotations.
>
> An object that is ISubscribingAware promises that there is an adapter
> adapting it to ISubscriber.
>
> Or am I confusing things?
It's a bit different. ISubscribingAware is an interface that an object
uses to be informed when it has been subscribed to something. That is,
if an object implements ISubscribingAware (or, soon, can be adapted to
implement it) then it will be informed when it has been subscribed and
unsubscribed to an ISubscribable. This allows third-party subscriptions
of objects that must do some work when they are subscribed and unsubscribed.
What Steve proposed is simply that the event service always ask the
adapter service to adapt any object that has been set as a listener to
ISubscriber. That way the object does not have to implement
ISubscriber, but just have an adapter for it, to be finally informed in
whatever way is appropriate.
Similarly, if an object is unsubscribed or subscribed to a subscribable,
Steve proposed that the event service look for an adapter rather than
only allow listeners who themselves implement the interface.
This basically follows a decision we had all made earlier on the list
(or perhaps it was a Papal decree, I don't remember) that we should
generally try to use adapters as much as possible in the core tools so
that the ComponentArchitecture always has a chance to do its magic
everywhere.
Gary