From 119cc0469a798b4731d65f32c597b5035a39a7d9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Wed, 1 Feb 2006 13:10:51 +0000
Subject: [PATCH] Reraise ValidationFailed, they should be catched by calling
 scripts.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@5494 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/patches/DCWorkflow.py | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/product/ERP5Type/patches/DCWorkflow.py b/product/ERP5Type/patches/DCWorkflow.py
index 408a0f8520..72caa720ad 100755
--- a/product/ERP5Type/patches/DCWorkflow.py
+++ b/product/ERP5Type/patches/DCWorkflow.py
@@ -117,6 +117,7 @@ def DCWorkflowDefinition_executeTransition(self, ob, tdef=None, kwargs=None):
     sci = None
     econtext = None
     moved_exc = None
+    validation_exc = None
 
     # Figure out the old and new states.
     old_sdef = self._getWorkflowStateOf(ob)
@@ -194,7 +195,12 @@ def DCWorkflowDefinition_executeTransition(self, ob, tdef=None, kwargs=None):
         tool.setStatusOf(self.id, ob, status)
         sci = StateChangeInfo(
             ob, self, status, tdef, old_sdef, new_sdef, kwargs)
-        sci.setWorkflowVariable(ob, workflow_id=self.id, error_message = before_script_error_message)
+        # put the error message in the workflow history
+        sci.setWorkflowVariable(ob, workflow_id=self.id,
+                                error_message = before_script_error_message)
+        if validation_exc :
+            # reraise validation failed exception
+            raise validation_exc
         return new_sdef
 
     # Update state.
@@ -202,11 +208,6 @@ def DCWorkflowDefinition_executeTransition(self, ob, tdef=None, kwargs=None):
     tool = aq_parent(aq_inner(self))
     tool.setStatusOf(self.id, ob, status)
 
-    # Make sure that the error message is empty. # Why ?
-    #sci = StateChangeInfo(
-    #    ob, self, status, tdef, old_sdef, new_sdef, kwargs)
-    #sci.setWorkflowVariable(ob, error_message = '')
-
     # Update role to permission assignments.
     self.updateRoleMappingsFor(ob)
 
-- 
2.30.9