[Erp5-report] r25038 - /erp5/trunk/products/ERP5Type/patches/WorkflowTool.py

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Jan 8 11:10:31 CET 2009


Author: vincent
Date: Thu Jan  8 11:10:21 2009
New Revision: 25038

URL: http://svn.erp5.org?rev=25038&view=rev
Log:
New worklist cache behaviour to avoid problems when alarm and users were triggering a refresh in parallel:
- only the alarm can trigger a worklist refresh
- refreshing uses DELETE/INSERT instead of DROP/CREATE/INSERT.

Modified:
    erp5/trunk/products/ERP5Type/patches/WorkflowTool.py

Modified: erp5/trunk/products/ERP5Type/patches/WorkflowTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/patches/WorkflowTool.py?rev=25038&r1=25037&r2=25038&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/patches/WorkflowTool.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/patches/WorkflowTool.py [utf8] Thu Jan  8 11:10:21 2009
@@ -34,6 +34,7 @@
 from Persistence import Persistent
 from Globals import PersistentMapping
 from itertools import izip
+from MySQLdb import ProgrammingError
 
 def DCWorkflowDefinition_notifyWorkflowMethod(self, ob, transition_list, args=None, kw=None):
     '''
@@ -557,6 +558,14 @@
 WorkflowTool.listActions = WorkflowTool_listActions
 
 def WorkflowTool_refreshWorklistCache(self):
+  """
+    Refresh worklist cache table.
+
+    - delete everything from that table
+      - if it fails, create the table
+    - insert new lines
+      - if it fails, recrete the table and retry
+  """
   # Contrary to WorkflowTool_listActions, related keys are NOT supported.
   Base_zInsertIntoWorklistTable = getattr(self, 'Base_zInsertIntoWorklistTable', None)
   if Base_zInsertIntoWorklistTable is not None:
@@ -572,7 +581,14 @@
           worklist_dict[wf_id] = a
     # End of duplicated code
     if len(worklist_dict):
-      self.Base_zCreateWorklistTable() # Create (or flush existing) table
+      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()
@@ -613,7 +629,14 @@
             if column_id in value_column_dict:
               value_column_dict[column_id].append(value)
         if len(value_column_dict[COUNT_COLUMN_TITLE]):
-          Base_zInsertIntoWorklistTable(**value_column_dict)
+          try:
+            Base_zInsertIntoWorklistTable(**value_column_dict)
+          except ProgrammingError:
+            LOG('WorkflowTool', 100, 'Insertion in worklist cache table ' \
+                'failed. Recreating table and retrying.',
+                error=sys.exc_info())
+            self.Base_zCreateWorklistTable()
+            Base_zInsertIntoWorklistTable(**value_column_dict)
 
 WorkflowTool.refreshWorklistCache = WorkflowTool_refreshWorklistCache
 




More information about the Erp5-report mailing list