From a963bb7a108871b46fb5c22dd915589507f810d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Calonne?= <aurel@nexedi.com> Date: Mon, 13 Mar 2006 19:51:34 +0000 Subject: [PATCH] add init method to ValidationFailed class to register Message instance modify executeTransition to register the message class in error_message for history git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6085 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Type/patches/DCWorkflow.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/product/ERP5Type/patches/DCWorkflow.py b/product/ERP5Type/patches/DCWorkflow.py index cbcb433451..262f4315c5 100755 --- a/product/ERP5Type/patches/DCWorkflow.py +++ b/product/ERP5Type/patches/DCWorkflow.py @@ -26,6 +26,7 @@ from DateTime import DateTime from Products.ERP5Type.Cache import CachingMethod from Products.ERP5Type.Utils import convertToMixedCase from string import join +from zLOG import LOG def DCWorkflowDefinition_listGlobalActions(self, info): ''' @@ -100,7 +101,13 @@ DCWorkflowDefinition.listGlobalActions = DCWorkflowDefinition_listGlobalActions class ValidationFailed(Exception): """Transition can not be executed because data is not in consistent state""" - + def __init__(self, message_instance=None): + """ + Redefine init in order to register the message class instance + """ + Exception.__init__(self) + self.msg = message_instance + DCWorkflow.ValidationFailed = ValidationFailed ModuleSecurityInfo('Products.DCWorkflow.DCWorkflow').declarePublic('ValidationFailed') @@ -148,7 +155,7 @@ def DCWorkflowDefinition_executeTransition(self, ob, tdef=None, kwargs=None): script(sci) # May throw an exception. except ValidationFailed, validation_exc: before_script_success = 0 - before_script_error_message = str(validation_exc) + before_script_error_message = validation_exc.msg except ObjectMoved, moved_exc: ob = moved_exc.getNewObject() # Re-raise after transition @@ -160,7 +167,7 @@ def DCWorkflowDefinition_executeTransition(self, ob, tdef=None, kwargs=None): if tdef is not None: tdef_exprs = tdef.var_exprs if tdef_exprs is None: tdef_exprs = {} status = {} - for id, vdef in self.variables.items(): + for id, vdef in self.variables.items(): if not vdef.for_status: continue expr = None -- 2.30.9