Chris Withers wrote:
> Martin Aspeli wrote:
>> To subscribe only to particular transitions, you would need for each
>> transition object to provide a specific interface.
> Unless you could leverage the same kind of thing that makes named
> adapters work...
Like the code I proposed? You are still then hardcoding (probably in ZCML) a
relationship between event handlers and transition names (which are editable
TTW), of course.
>> zope.event?), it registers a general subscriber for IObjectEvent and then
>> redispatches for multi-subscribers based on (obj, event), i.e. you
>> a handler for the object type and for the event type.
> I actually don't like this pattern, it seems needlessly inefficient. Why
> not just set the right damned event going from the start? ;-)
It's only one layer of indirection, probably equivalent to a fast search (I
assume the adapter registry uses trees) and a function call. There is a
single implementation of this for any IObjectEvent, in fact, so since the
workflow events are IObjectEvents, you'll get redispatch for free (this was
If you want named redispatch, you'll need to make your own redispatcher -
but that's preciely the point. No generic code could know that it's
event.transition_name or whatever that is the name to redispatch upon. :)
>> We could do the same for a transition event, e.g. re-dispatching based on
>> object type, workflow type and/or transition type.
> Sounds like it would fit the idiom, even if I don't like it...
Think of it as framework code you don't have to see or worry about if it
were written once. But again, there is no per-transition interface (all
transition definition objects are of the same class, just with different
names), so redispatch on interface would be tricky.
> Yeah, decorators suck when abused and zcml just sucks ;-)
So use zope.component.provideAdapter/provideHandler.
View this message in context:
Sent from the Zope - CMF list2 mailing list archive at Nabble.com.
Zope-CMF maillist - Zope-CMF@lists.zope.org
See http://collector.zope.org/CMF for bug reports and feature requests