[Erp5-report] r15219 - /erp5/trunk/products/ERP5Type/Core/Folder.py

nobody at svn.erp5.org nobody at svn.erp5.org
Sun Jul 15 22:26:01 CEST 2007


Author: jp
Date: Sun Jul 15 22:26:00 2007
New Revision: 15219

URL: http://svn.erp5.org?rev=15219&view=rev
Log:
added optimization to recursiveReindexObject so that it is possible to call it on a module or on a large folder without creating huge transactions

Modified:
    erp5/trunk/products/ERP5Type/Core/Folder.py

Modified: erp5/trunk/products/ERP5Type/Core/Folder.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Core/Folder.py?rev=15219&r1=15218&r2=15219&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Core/Folder.py (original)
+++ erp5/trunk/products/ERP5Type/Core/Folder.py Sun Jul 15 22:26:00 2007
@@ -55,6 +55,8 @@
 
 from zLOG import LOG, PROBLEM
 import warnings
+
+REINDEX_SPLIT_COUNT = 100 # if folder containes more than this, reindexing should be splitted.
 
 # Dummy Functions for update / upgrade
 def dummyFilter(object,REQUEST=None):
@@ -575,6 +577,20 @@
       BUG here : when creating a new base category
     """
     if self.isIndexable:
+      if activate_kw is None and self.objectCount() > REINDEX_SPLIT_COUNT:
+        # If the number of objects to reindex is too high
+        # we should try to split reindexing in order to be more efficient
+        # NOTE: this heuristic will fail for example with orders which
+        # contain > REINDEX_SPLIT_COUNT order lines.
+        # It will be less efficient in this case. We also do not
+        # use this heuristic whenever activate_kw is defined
+        self._reindexObject(**kw)
+        for c in self.objectValues():
+          if getattr(aq_base(c),
+                    'recursiveReindexObject', None) is not None:
+            c.recursiveReindexObject(**kw)
+        return
+
       if activate_kw is None:
         activate_kw = {}
 




More information about the Erp5-report mailing list