[Zope-CMF] Zope 3 events from workflow
    Martin Aspeli 
    optilude at gmx.net
       
    Tue Dec 26 10:43:26 EST 2006
    
    
  
Hi guys,
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)
 From what I can tell, something like this would work:
from zope.component.interfaces import IObjectEvent
from zope.schema import TextLine
class IWorkflowEvent(IObjectEvent):
     """A workflow related event
     """
     wf_name = TextLine(title=u"The name of the workflow this event is 
part of")
     transition = TextLine(title=u"The name of the transition taking place")
     state_before = TextLine(title=u"The object's state before the 
transition")
     state_after = TextLine(title=u"The object's state after the 
transition")
class IBeforeTransitionEvent(IWorkflowEvent):
     """A transition is about to take place
     """
class IAfterTransitionEvent(IWorkflowEvent):
     """A transition has just taken place
     """
...
from zope.component import ObjectEvent
from interfaces import IBeforeTransitionEvent, IAfterTransitionEvent
class WorkflowEvent(ObjectEvent):
     def __init__(self, object, wf_name, transition, state_before, 
state_after):
         self.object = object
         self.wf_name = wf_name
         self.transition = transition
         self.state_before = state_before
         self.state_after = state_after
class BeforeTransitionEvent(WorkflowEvent):
     implements(IBeforeTransitionEvent)
class AfterTransitionEvent(WorkflowEvent):
     implements(IAfterTransitionEvent)
...
I'm not quite sure where the best place to execute the event is. One 
option may be DCWorkflow/DCWorkflow.py, 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.
Would appreciate some suggestions or help to get this in, if you agree 
it's a good idea (note, I don't have commit privs to CMF at this point).
Martin
    
    
More information about the Zope-CMF
mailing list