From fc6e9b7cf84f19117c446d523e68c50b4c9de18c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20G=C3=B3rny?= <bartek@gorny.edu.pl> Date: Mon, 11 Dec 2006 17:40:40 +0000 Subject: [PATCH] after conversion - conditional validation in try/except block re-raise exception if something goes wrong to prevent repeated activities git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11674 20353a03-c40f-0410-a6d1-a30d3c3de9de --- .../erp5_dms/OOoDocument_convertAfter.xml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/OOoDocument_convertAfter.xml b/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/OOoDocument_convertAfter.xml index 7035fe2e1c..5476b7c8a1 100644 --- a/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/OOoDocument_convertAfter.xml +++ b/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/OOoDocument_convertAfter.xml @@ -68,7 +68,9 @@ </item> <item> <key> <string>_body</string> </key> - <value> <string>ob=context\n + <value> <string>from Products.DCWorkflow.DCWorkflow import ValidationFailed\n +\n +ob=context\n context.log(kw)\n if (ob.hasFile() and not ob.hasOOFile()) or context.REQUEST.get(\'force\'): #doublecheck\n context.log(\'we go ahead\')\n @@ -76,11 +78,15 @@ if (ob.hasFile() and not ob.hasOOFile()) or context.REQUEST.get(\'force\'): #dou res=ob.convert(force=1)\n ob.setPropertyListFromContent()\n ob.setExternalProcessingStatusMessage(\'converted\')\n - context.portal_workflow.doActionFor(context,\'validate_action\')\n + if context.getValidationState()!=\'validated\':\n + context.portal_workflow.doActionFor(context,\'validate_action\')\n + except ValidationFailed,e:\n + ob.log(\'Exception\',e)\n + ob.setExternalProcessingStatusMessage(str(e))\n except Exception,e:\n ob.log(\'Exception\',e)\n ob.setExternalProcessingStatusMessage(str(e))\n - #raise Exception(str(e)) # do we want the activity to keep trying?\n + raise Exception(str(e)) # do we want the activity to keep trying? - no, we don\'t, this will cause endless loop\n </string> </value> </item> <item> @@ -131,13 +137,15 @@ if (ob.hasFile() and not ob.hasOOFile()) or context.REQUEST.get(\'force\'): #dou <tuple> <string>a</string> <string>kw</string> + <string>Products.DCWorkflow.DCWorkflow</string> + <string>ValidationFailed</string> <string>context</string> <string>ob</string> <string>_getattr_</string> <string>res</string> - <string>Exception</string> <string>e</string> <string>str</string> + <string>Exception</string> </tuple> </value> </item> -- 2.30.9