diff --git a/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_ingestion_workflow/scripts/test_error_message.xml b/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_ingestion_workflow/scripts/test_error_message.xml deleted file mode 100644 index 4d98610591c11702b73a24dbcf0637b91de0b922..0000000000000000000000000000000000000000 --- a/bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_ingestion_workflow/scripts/test_error_message.xml +++ /dev/null @@ -1,84 +0,0 @@ -<?xml version="1.0"?> -<ZopeData> - <record id="1" aka="AAAAAAAAAAE="> - <pickle> - <global name="PythonScript" module="Products.PythonScripts.PythonScript"/> - </pickle> - <pickle> - <dictionary> - <item> - <key> <string>Script_magic</string> </key> - <value> <int>3</int> </value> - </item> - <item> - <key> <string>_bind_names</string> </key> - <value> - <object> - <klass> - <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/> - </klass> - <tuple/> - <state> - <dictionary> - <item> - <key> <string>_asgns</string> </key> - <value> - <dictionary> - <item> - <key> <string>name_container</string> </key> - <value> <string>container</string> </value> - </item> - <item> - <key> <string>name_context</string> </key> - <value> <string>context</string> </value> - </item> - <item> - <key> <string>name_m_self</string> </key> - <value> <string>script</string> </value> - </item> - <item> - <key> <string>name_subpath</string> </key> - <value> <string>traverse_subpath</string> </value> - </item> - </dictionary> - </value> - </item> - </dictionary> - </state> - </object> - </value> - </item> - <item> - <key> <string>_body</string> </key> - <value> <string>transition = state_change[\'transition\'].id[len(\'user_\'):]\n -\n -def TestTitle(object):\n - """\n - This is the test for this particular action\n - """\n - if object.getTitle() == \'truc\':\n - return 1\n - return 0\n -\n -object = state_change[\'object\']\n -\n -if TestTitle(object):\n - method = getattr(context, transition)\n - method()\n -else:\n - kw = {\'error_message\':\'Why do you want to do this ?????\'}\n - state_change.setWorkflowVariable(object, **kw)\n -</string> </value> - </item> - <item> - <key> <string>_params</string> </key> - <value> <string>state_change</string> </value> - </item> - <item> - <key> <string>id</string> </key> - <value> <string>test_error_message</string> </value> - </item> - </dictionary> - </pickle> - </record> -</ZopeData> diff --git a/product/ERP5Type/patches/DCWorkflow.py b/product/ERP5Type/patches/DCWorkflow.py index 00771dade6fca1cee9e707f28a1ce6ba71c59aa9..2d60be399cc5a5351121b47bf20b4909a88cb9a3 100644 --- a/product/ERP5Type/patches/DCWorkflow.py +++ b/product/ERP5Type/patches/DCWorkflow.py @@ -400,8 +400,7 @@ def DCWorkflowDefinition_executeTransition(self, ob, tdef=None, kwargs=None): sci = StateChangeInfo( ob, self, status, tdef, old_sdef, new_sdef, kwargs) # put the error message in the workflow history - sci.setWorkflowVariable(ob, workflow_id=self.id, - error_message = before_script_error_message) + sci.setWorkflowVariable(error_message=before_script_error_message) if validation_exc : # reraise validation failed exception raise validation_exc, None, validation_exc_traceback diff --git a/product/ERP5Type/patches/StateChangeInfoPatch.py b/product/ERP5Type/patches/StateChangeInfoPatch.py index 6d8177fd7e2c6efcd9b50cf0c66013cbd19e6319..7b90e146d04228acbf9d0dda326c27817ccb4330 100644 --- a/product/ERP5Type/patches/StateChangeInfoPatch.py +++ b/product/ERP5Type/patches/StateChangeInfoPatch.py @@ -30,19 +30,14 @@ from Products.DCWorkflow.Expression import StateChangeInfo from Products.PythonScripts.Utility import allow_class allow_class(StateChangeInfo) -def setWorkflowVariable(self, object, workflow_id='edit_workflow',**kw): +def setWorkflowVariable(self, **kw): """ Allows to go through security checking and let a script allows to modify a workflow variable """ - workflow_history = object.workflow_history - for workflow in workflow_history.keys(): - if len(workflow_history[workflow])!= 0 and workflow==workflow_id: - last_status = workflow_history[workflow][-1] - for variable in kw.keys(): - if last_status.has_key(variable): - last_status[variable]=kw[variable] - + history = self.object.workflow_history[self.workflow.id] + history[-1].update(kw) + history._p_changed = 1 StateChangeInfo.setWorkflowVariable = setWorkflowVariable