From 782ef7a5c090fb8925ef5305751e1788a46fdf3d Mon Sep 17 00:00:00 2001
From: Vincent Pelletier <vincent@nexedi.com>
Date: Thu, 8 Jan 2009 10:12:56 +0000
Subject: [PATCH] Add backward compatibility with former business template.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25039 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/patches/WorkflowTool.py | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/product/ERP5Type/patches/WorkflowTool.py b/product/ERP5Type/patches/WorkflowTool.py
index e545b8cbd0..34d01f1aea 100644
--- a/product/ERP5Type/patches/WorkflowTool.py
+++ b/product/ERP5Type/patches/WorkflowTool.py
@@ -581,14 +581,21 @@ def WorkflowTool_refreshWorklistCache(self):
           worklist_dict[wf_id] = a
     # End of duplicated code
     if len(worklist_dict):
-      try:
-        self.Base_zClearWorklistTable()
-      except ProgrammingError, error_value:
-        import pdb; pdb.set_trace()
-        # 1146 = table does not exist
-        if error_value[0] != 1146:
-          raise
+      Base_zClearWorklistTable = getattr(self, 'Base_zClearWorklistTable', None)
+      if Base_zClearWorklistTable is None:
+        LOG('WorkflowTool', 100, 'Base_zClearWorklistTable cannot be found. ' \
+            'Falling back to former refresh method. Please update ' \
+            'erp5_worklist_sql business template.')
         self.Base_zCreateWorklistTable()
+      else:
+        try:
+          self.Base_zClearWorklistTable()
+        except ProgrammingError, error_value:
+          import pdb; pdb.set_trace()
+          # 1146 = table does not exist
+          if error_value[0] != 1146:
+            raise
+          self.Base_zCreateWorklistTable()
       portal_catalog = getToolByName(self, 'portal_catalog')
       search_result = portal_catalog.unrestrictedSearchResults
       acceptable_key_dict = portal_catalog.getSQLCatalog().getColumnMap()
-- 
2.30.9