Jens Vagelpohl wrote:
Hash: SHA1

Am I right in thinking that DCWorkflow does not send any Zope 3 events? I'm not terribly familiar with that code, but some grepping suggests so.

Do you agree this would be useful? (I've got a pretty strong need for it for Plone 3, i.e. CMF 2.1 - I'm sure we can work around it in Plone, but I'd rather do it properly)

It is definitely useful in the general migration towards more event-based processing.

I'm not quite sure where the best place to execute the event is. One option may be DCWorkflow/, in notifyBefore() and notifySuccess(). Here, though, I get a bit confused about how to construct the wf_name and state_before/state_after parameters. I guess they're not always needed, but they seem like they'd be useful to most event handlers.

Eyeballing the code seems to suggest DCWorkflowDefinition._executeTransition as the place where both the old state and the new state are known.

If events are used I'm not sure what the notify*-Methods would be used for anymore.

Thanks Jens!

Considering that I don't have CMF commit privs (I know, shame on me - do I need to go get a Zope Foundation contributor agreement off by snail mail? At least I can't do that for a bit, since I'm on holiday), but also that I'm not terribly comfortable with the DCWorkflow code, is there someone that's willing to run with this?

I think the event definitions I posted would work, so it'd only be matter of putting these in the interfaces package and calling notify() with the right information in the right place.

As far as writing tests, what I normally do is set up a dummy handler using provideSubscriber() in a doctest and have this print something.

>>> from zope.interface import Interface
>>> from zope.component import adapter
>>> from Products.CMFCore.interfaces import IBeforeTransitionEvent

>>> @adapter(Interface, IBeforeTransitionEvent)
... def test_handler(obj, event):
... print "Before transition: %s, from %s to %s" % (event.transition, event.before_state, event.after_state,)

>>> from zope.component import provideHandler
>>> provideHandler(test_handler)

>>> # trigger a workflow transition somewhere
Before transition: publish, from visible to published

That is, in a doctest you can test for the print output of the event handler quite easily.

Right, I hope that helps anyway - sorry I can't just put it in myself right now, but if someone else has a need or a wish, I'd be really grateful if they could shepherd this in. :)


Zope-CMF maillist  -

See for bug reports and feature requests

Reply via email to