From 0d24c12d5132f974f6b52a7c57769e9860313f4a 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:43:38 +0000
Subject: [PATCH] after conversion, trigger also a post-conversion script
 validate conditionally, fail silently if not valid

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11675 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../portal_skins/erp5_dms/DMS_ingestFile.xml          | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/DMS_ingestFile.xml b/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/DMS_ingestFile.xml
index 9b411a58ee..c67048ee26 100644
--- a/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/DMS_ingestFile.xml
+++ b/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/DMS_ingestFile.xml
@@ -71,7 +71,7 @@
             <value> <string># this script does not save file data in a document\n
 # it can be run any time\n
 # is meant to extract metadata from file name and contents\n
-\n
+from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
 if data is None:\n
   if hasattr(context,\'oo_data\'):\n
     data=context.oo_data\n
@@ -96,9 +96,12 @@ if fname is not None:\n
   if hasattr(context,\'convert\') and hasattr(context,\'hasFile\') and hasattr(context,\'hasOOFile\'):\n
     context.reset()\n
     if context.hasFile() and not context.hasOOFile():\n
-      context.activate( activity  = \'SQLQueue\').OOoDocument_convertAfter()\n
-  else:\n
+      context.activate().OOoDocument_convertAfter()\n
+      context.activate(after_method_id=\'OOoDocument_convertAfter\').OOoDocument_postConversion()\n
+  try:\n
     context.portal_workflow.doActionFor(context,\'validate_action\')\n
+  except ValidationFailed:\n
+    pass # we do not want to throw exception, just leave the document not validated\n
 </string> </value>
         </item>
         <item>
@@ -149,6 +152,8 @@ if fname is not None:\n
                           <tuple>
                             <string>fname</string>
                             <string>data</string>
+                            <string>Products.DCWorkflow.DCWorkflow</string>
+                            <string>ValidationFailed</string>
                             <string>None</string>
                             <string>hasattr</string>
                             <string>context</string>
-- 
2.30.9