[Zope3-dev] discussion about ObjectHub, EventService etc. (was
event-meta.zcml...)
Steve Alexander
s.alexander@lancaster.ac.uk
Wed, 18 Dec 2002 16:21:41 +0000
>> So, an ObjectHub should not be referenced directly. It needs to have a
>> context so that it can notify its subscribers in context.
>>
>> The only things that can subscribe by reference are "leaf" subscribers
>> that don't themselves have further subscribers, and event channels
>> where all of the subscribers to that event channel subscribe by reference
>
>
> Shouldn't the current "subscribe/globalSubscribe" discussion also
> influence the local event channel subscription pattern in general? That
> would mean subscribe for all local event channels would be influenced as
> well.
Local event channels should be subscribed to by location or object hub
id. Is that what you meant?
> Also: you described at one point the behavior for passing a wrapped
> subscriber into the event service as meaning that the absoulte path is
> obtained and used for subscription, I believe. Would you buy that you
> first try for a hubid, and failing that, get the path?
That's a very interesting question. Do you have any suggestions on how
to flexibly support both path and hubId subscriptions?
Here are my thoughts:
The relationship between object and locations and hubIds is like this:
object <---> location <---> hubId
| |
traversal ObjectHub service
So, you need to get a path in order to get a hubId.
If I have an object, the steps involved to get a location and a hubId are:
location = getPhysicalPath(object)
hubId = getService(here, 'ObjectHub').getHubId(location)
Actually, if we weren't concerned about locations, this would work too:
hubId = getService(here, 'ObjectHub').getHubId(object)
I'd like to keep things explicit. I'd also like to keep from too much
extra typing.
Perhaps the subscribe method could look a bit like this:
def subscribe(location_or_object, event_type=IEvent, filter=None):
and there could also be a method for subscribing by hubId:
def subscribeHubId(hubId_or_object, event_type=IEvent, filter=None):
These could be part of the IZopeSubscribable interface, which would be
implemented by all subscribables for use in the zope framework.
How does this sound to you?
> Also: use case for a local "directSubscribe" is that the local
> event-channel-like services subscribe directly because these are things
> that are system components and so can have direct (hard reference)
> connections as clients, rather than indirect path subscriptions. This
> works because of the whole ISubscriptionAware stuff. ...Do you buy it?
If we want to allow certain event channels to subscribe by direct
reference, we need to expand the ISubscriber interface for this case.
Somehow, the context needs to be passed along. We mustn't break the
context-passing chain if something later on in that chain needs to get
the context.
Currently, a subscriber that needs the context can get this from self
(or rather, wrapped_self) by making notify() a ContextMethod.
def notify(wrapped_self, event):
# method body
notify = ContextMethod(notify)
Then again, perhaps we want to pass the context explicitly to notify().
def notify(self, event, context=None):
# method body
There could be a separate IContextSubscriber interface for this.
> I'd like to try and get the event stuff settled asap because I think I
> can work on it today. :-)
Great.
--
Steve Alexander