From 35ce24202aceaa684e42ec4431b310e0162b14b0 Mon Sep 17 00:00:00 2001
From: Yoshinori Okuji <yo@nexedi.com>
Date: Wed, 25 Feb 2004 14:30:42 +0000
Subject: [PATCH] Fix simple mistakes in the previous change.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@511 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/ZopePatch.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/product/ERP5Type/ZopePatch.py b/product/ERP5Type/ZopePatch.py
index 65576ddf34..f0bca2aedd 100755
--- a/product/ERP5Type/ZopePatch.py
+++ b/product/ERP5Type/ZopePatch.py
@@ -510,6 +510,7 @@ class ERP5DCWorkflowDefinition (DCWorkflowDefinition):
             sci = StateChangeInfo(
                 ob, self, former_status, tdef, old_sdef, new_sdef, kwargs)
             try:
+                LOG('_executeTransition', 0, "script = %s, sci = %s" % (repr(script), repr(sci)))
                 script(sci)  # May throw an exception.
             except ValidationFailed, validation_exc:
                 before_script_success = 0
@@ -568,15 +569,20 @@ class ERP5DCWorkflowDefinition (DCWorkflowDefinition):
         tool = aq_parent(aq_inner(self))
         tool.setStatusOf(self.id, ob, status)
 
+        # Make sure that the error message is empty.
+        sci = StateChangeInfo(
+            ob, self, status, tdef, old_sdef, new_sdef, kwargs)
+        sci.setWorkflowVariable(ob, error_message = '')
+
         # Update role to permission assignments.
         self.updateRoleMappingsFor(ob)
 
         # Execute the "after" script.
         if tdef is not None and tdef.after_script_name:
             # Script can be either script or workflow method
-            if after_script_name in filter(lambda k: self.transitions[k].trigger_type == TRIGGER_WORKFLOW_METHOD,
-                                                                                     new_sdef.transitions.keys()):
-              script = getattr(ob, after_script_name)
+            if tdef.after_script_name in filter(lambda k: self.transitions[k].trigger_type == TRIGGER_WORKFLOW_METHOD,
+                                                                                     new_sdef.transitions):
+              script = getattr(ob, tdef.after_script_name)
               script()
             else:
               script = self.scripts[tdef.after_script_name]
-- 
2.30.9