[Erp5-report] r42116 jm - /erp5/trunk/products/ERP5Type/patches/DCWorkflow.py

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Jan 7 14:42:24 CET 2011


Author: jm
Date: Fri Jan  7 14:42:24 2011
New Revision: 42116

URL: http://svn.erp5.org?rev=42116&view=rev
Log:
Do not initialize history for workflows that have no state at all

Since commit 38864 (hide worklist if for portal types that are not chained to
the workflow), we may want to create workflows that only contain worklists,
without polluting histories.

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

Modified: erp5/trunk/products/ERP5Type/patches/DCWorkflow.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/patches/DCWorkflow.py?rev=42116&r1=42115&r2=42116&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/patches/DCWorkflow.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/patches/DCWorkflow.py [utf8] Fri Jan  7 14:42:24 2011
@@ -308,21 +308,22 @@ def DCWorkflowDefinition_executeTransiti
     validation_exc = None
 
     # Figure out the old and new states.
-    old_sdef = self._getWorkflowStateOf(ob)
-    old_state = old_sdef.getId()
+    old_state = self._getWorkflowStateOf(ob, True)
     if tdef is None:
         new_state = self.initial_state
+        if not new_state:
+            # Do nothing if there is no initial state. We may want to create
+            # workflows with no state at all, only for worklists.
+            return
         former_status = {}
     else:
-        new_state = tdef.new_state_id
-        if not new_state:
-            # Stay in same state.
-            new_state = old_state
+        new_state = tdef.new_state_id or old_state
         former_status = self._getStatusOf(ob)
-    new_sdef = self.states.get(new_state, None)
-    if new_sdef is None:
-        raise WorkflowException, (
-            'Destination state undefined: ' + new_state)
+    old_sdef = self.states[old_state]
+    try:
+        new_sdef = self.states[new_state]
+    except KeyError:
+        raise WorkflowException('Destination state undefined: ' + new_state)
 
     # Execute the "before" script.
     before_script_success = 1



More information about the Erp5-report mailing list