[Zope3-dev] Subscriber Ordering
Jim Fulton
jim at zope.com
Thu Nov 4 15:40:18 EST 2004
Currently, the order that subscription adapters are called in is
undefined [1]_. Sometimes, we *do* want some control over the order
of subscriber notification. There are a number of ways to do this:
1. You can publish multiple events. This has the disadvantage that
the publisher of the events has to be aware of the desired
ordering. It doesn't work if the ordering is a policy of the
subscribers themselves.
2. If a subscriber needs to come after some earlier subscriber, we
have the earlier subscriber generate an event. The later subscriber
subscribes to the event generated by the earlier subscriber, rather
than to the original event. This requires the collaboration of the
subscribers to implement the policy.
It would be nice, at times, to provide the ordering policy outside the
subscribers and the notifiers. Here is an idea.
- We allow subscribers to be named. There could be multiple
subscribers of the same type [2]_ and name, so the names will
really name classes of subscribers.
- A notifier could support ordered subscribers by allowing a sequence
of subscriber classes to be specified. It will then call the
subscribers in each class in the order the classes were configured.
For example, the pluggable authentication service (PAS) might use
this method to order its principal-creation subscribers.
- Alternatively, we could register an unnamed subscriber (for a
subscriber type) that had a list of subscriber (class) named
and called the subscribers for each class in order.
This feels like a conceptually straightforward model and is
sufficiently powerful, for example to handle PAS's subscription
requirements. [3]_
Thoughts?
Jim
.. [1] The implementation happens to implement a fixed order. More
specific subscribers are invoked before less-specific
subscribers and subscribers of the same type are called in
registration order.
.. [2] A subscriber type, which is also an adapter type, which is the
combination of the required (adapted) specifications and the
provided interface.
.. [3] It would also make it possible to use subscribers rather than
utilities for credential extraction and challenge, which would,
I think, be cleaner, as it would allow components to be
registered by request type.
--
Jim Fulton mailto:jim at zope.com Python Powered!
CTO (540) 361-1714 http://www.python.org
Zope Corporation http://www.zope.com http://www.zope.org
More information about the Zope3-dev
mailing list