[Zope-CMF] Workflow aware objects
Florent Guillaume
fg@nuxeo.com
28 Sep 2001 17:48:00 GMT
I'd like to propose the following addition to the Workflow Tool.
With this, I can have objects that react to their state change.
Currently if I want to do this, I have to use, in DCWorkflow, a
transition script, with the unfortunate gotcha that this script is
called just before the transition has its new "status" (thus if I want
to use the future status, I have to regenerate it by hand), and all in
all it's not very clean.
The kind of objects I would use this for is a "Dossier" (which I'll
release soon), which is like a folder whose children objects have a
workflow state slaved to the Dossier's workflow state. It makes it very
easy to have "collection" objects (the Dossier inherits from my
PortalContentFolder, which is basically a PortalFolder with contentish
properties (workflow, catalog)).
Thanks,
Florent Guillaume
Nuxeo
--- WorkflowTool.py.orig Fri Sep 28 11:40:17 2001
+++ WorkflowTool.py Fri Sep 28 12:19:27 2001
@@ -588,34 +588,43 @@
def notifyBefore(self, ob, action):
'''
Notifies all applicable workflows of an action before it happens,
allowing veto by exception. Unless an exception is thrown, either
a notifySuccess() or notifyException() can be expected later on.
The action usually corresponds to a method name.
+ Also notifies workflow-aware objects.
'''
wfs = self.getWorkflowsFor(ob)
for wf in wfs:
wf.notifyBefore(ob, action)
+ if getattr(ob, '_isWorkflowAware', 0):
+ ob.workflowNotifyBefore(action)
security.declarePrivate('notifySuccess')
def notifySuccess(self, ob, action, result=None):
'''
Notifies all applicable workflows that an action has taken place.
+ Also notifies workflow-aware objects.
'''
wfs = self.getWorkflowsFor(ob)
for wf in wfs:
wf.notifySuccess(ob, action, result)
+ if getattr(ob, '_isWorkflowAware', 0):
+ ob.workflowNotifySuccess(action, result)
security.declarePrivate('notifyException')
def notifyException(self, ob, action, exc):
'''
Notifies all applicable workflows that an action failed.
+ Also notifies workflow-aware objects.
'''
wfs = self.getWorkflowsFor(ob)
for wf in wfs:
wf.notifyException(ob, action, exc)
+ if getattr(ob, '_isWorkflowAware', 0):
+ ob.workflowNotifyException(action, exc)
security.declarePrivate('getHistoryOf')
def getHistoryOf(self, wf_id, ob):
'''
Invoked by workflow definitions. Returns the history
of an object.
--
Florent Guillaume, Nuxeo SARL (Paris, France)
+33 1 40 33 79 87 http://nuxeo.com mailto:fg@nuxeo.com