[CMF-checkins] CVS: CMF/DCWorkflow - DCWorkflow.py:1.9
Shane Hathaway
shane@digicool.com
Wed, 24 Oct 2001 14:06:43 -0400
Update of /cvs-repository/CMF/DCWorkflow
In directory cvs.zope.org:/tmp/cvs-serv5201
Modified Files:
DCWorkflow.py
Log Message:
This experimental change causes automatic transitions to occur when
any workflow does something.
=== CMF/DCWorkflow/DCWorkflow.py 1.8 => 1.9 ===
Notifies this workflow that an action has taken place.
'''
- pass
+ # Take the opportunity to execute automatic transitions.
+ sdef = self._getWorkflowStateOf(ob)
+ if sdef is not None:
+ tdef = self._findAutomaticTransition(ob, sdef)
+ if tdef is not None:
+ self._changeStateOf(self, ob, tdef)
security.declarePrivate('notifyException')
def notifyException(self, ob, action, exc):
@@ -486,6 +491,16 @@
if guard.check(getSecurityManager(), self, ob):
return 1
return 0
+
+ def _findAutomaticTransition(self, ob, sdef):
+ tdef = None
+ for tid in sdef.transitions:
+ t = self.transitions.get(tid, None)
+ if t is not None and t.trigger_type == TRIGGER_AUTOMATIC:
+ if self._checkTransitionGuard(t, ob):
+ tdef = t
+ break
+ return tdef
def _changeStateOf(self, ob, tdef=None, kwargs=None):
'''
@@ -503,13 +518,7 @@
sdef = self._getWorkflowStateOf(ob)
if sdef is None:
break
- tdef = None
- for tid in sdef.transitions:
- t = self.transitions.get(tid, None)
- if t is not None and t.trigger_type == TRIGGER_AUTOMATIC:
- if self._checkTransitionGuard(t, ob):
- tdef = t
- break
+ tdef = self._findAutomaticTransition(ob, sdef)
if tdef is None:
# No more automatic transitions.
break