[Erp5-report] r25085 - in /erp5/trunk/products/ERP5Type/patches: DCWorkflow.py WorkflowTool.py

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Jan 12 15:44:24 CET 2009


Author: jm
Date: Mon Jan 12 15:44:22 2009
New Revision: 25085

URL: http://svn.erp5.org?rev=25085&view=rev
Log:
Add a method on workflows to get all states that can be reached from a given state, directly or not.

Modified:
    erp5/trunk/products/ERP5Type/patches/DCWorkflow.py
    erp5/trunk/products/ERP5Type/patches/WorkflowTool.py

Modified: erp5/trunk/products/ERP5Type/patches/DCWorkflow.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/patches/DCWorkflow.py?rev=25085&r1=25084&r2=25085&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/patches/DCWorkflow.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/patches/DCWorkflow.py [utf8] Mon Jan 12 15:44:22 2009
@@ -559,6 +559,27 @@
 
 DCWorkflowDefinition.getPortalTypeListForWorkflow = getPortalTypeListForWorkflow
 
+def DCWorkflowDefinition_getFutureStateSet(self, state, ignore=(),
+                                           _future_state_set=None):
+  """Return the states that can be reached from a given state, directly or not.
+
+  This method returns a set of ids of all states that can be reached in any
+  number of transitions, starting from the state specified by the 'state'
+  parameter. 'ignore' parameter is a list of states to ignore, as if there was
+  no transition to them.
+  """
+  if _future_state_set is None:
+    _future_state_set = set()
+  _future_state_set.add(state)
+  for transition in self.states[state].transitions:
+    state = self.transitions[transition].new_state_id
+    if state and state not in _future_state_set and state not in ignore:
+      self.getFutureStateSet(state, ignore, _future_state_set)
+  return _future_state_set
+
+DCWorkflowDefinition.getFutureStateSet = DCWorkflowDefinition_getFutureStateSet
+
+
 # This patch allows to use workflowmethod as an after_script
 # However, the right way of doing would be to have a combined state of TRIGGER_USER_ACTION and TRIGGER_WORKFLOW_METHOD
 # as well as workflow inheritance. This way, different user actions and dialogs can be specified easliy

Modified: erp5/trunk/products/ERP5Type/patches/WorkflowTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/patches/WorkflowTool.py?rev=25085&r1=25084&r2=25085&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/patches/WorkflowTool.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/patches/WorkflowTool.py [utf8] Mon Jan 12 15:44:22 2009
@@ -753,3 +753,6 @@
     wfh.append(status)
 
 WorkflowTool.setStatusOf = WorkflowTool_setStatusOf
+
+WorkflowTool.getFutureStateSetFor = lambda self, wf_id, *args, **kw: \
+  self[wf_id].getFutureStateSet(*args, **kw)




More information about the Erp5-report mailing list