[Erp5-report] r37691 yo - in /erp5/trunk/products/ERP5/Document: AppliedRule.py Delivery.py

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Aug 11 12:02:24 CEST 2010


Author: yo
Date: Wed Aug 11 12:02:22 2010
New Revision: 37691

URL: http://svn.erp5.org?rev=37691&view=rev
Log:
Skip reindexing Applied Rules unnecessarily when expanding simulation.

Modified:
    erp5/trunk/products/ERP5/Document/AppliedRule.py
    erp5/trunk/products/ERP5/Document/Delivery.py

Modified: erp5/trunk/products/ERP5/Document/AppliedRule.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/AppliedRule.py?rev=37691&r1=37690&r2=37691&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/AppliedRule.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/AppliedRule.py [utf8] Wed Aug 11 12:02:22 2010
@@ -275,3 +275,56 @@ class AppliedRule(XMLObject):
        Return a list of movements.
       """
       return self.objectValues(portal_type=Rule.movement_type)
+
+    security.declareProtected(Permissions.AccessContentsInformation,
+            'getIndexableChildSimulationMovementValueList')
+    def getIndexableChildSimulationMovementValueList(self):
+      return [x for x in self.getIndexableChildValueList() 
+              if x.getPortalType() == 'Simulation Movement']
+
+    security.declarePublic('recursiveImmediateReindexSimulationMovement')
+    def recursiveImmediateReindexSimulationMovement(self, **kw):
+      """
+        Applies immediateReindexObject recursively to Simulation Movements
+      """
+      # Reindex direct children
+      root_indexable = int(getattr(self.getPortalObject(), 'isIndexable', 1))
+      for movement in self.objectValues():
+        if movement.isIndexable and root_indexable:
+          movement.immediateReindexObject(**kw)
+      # Go recursively
+      for movement in self.objectValues():
+        for applied_rule in movement.objectValues():
+          applied_rule.recursiveImmediateReindexSimulationMovement(**kw)
+
+    security.declarePublic('recursiveReindexObject')
+    def recursiveReindexSimulationMovement(self, activate_kw=None, **kw):
+      if self.isIndexable:
+        if activate_kw is None:
+          activate_kw = {}
+
+      reindex_kw = self.getDefaultReindexParameterDict()
+      if reindex_kw is not None:
+        reindex_activate_kw = reindex_kw.pop('activate_kw', None)
+        if reindex_activate_kw is not None:
+          reindex_activate_kw = reindex_activate_kw.copy()
+          if activate_kw is not None:
+            # activate_kw parameter takes precedence
+            reindex_activate_kw.update(activate_kw)
+          activate_kw = reindex_activate_kw
+        kw.update(reindex_kw)
+
+      group_id_list  = []
+      if kw.get("group_id", "") not in ('', None):
+        group_id_list.append(kw.get("group_id", ""))
+      if kw.get("sql_catalog_id", "") not in ('', None):
+        group_id_list.append(kw.get("sql_catalog_id", ""))
+      group_id = ' '.join(group_id_list)
+
+      self.activate(group_method_id='portal_catalog/catalogObjectList',
+                    expand_method_id='getIndexableChildSimulationMovementValueList',
+                    alternate_method_id='alternateReindexObject',
+                    group_id=group_id,
+                    serialization_tag=self.getRootDocumentPath(),
+                    **activate_kw).recursiveImmediateReindexSimulationMovement(**kw)
+

Modified: erp5/trunk/products/ERP5/Document/Delivery.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/Delivery.py?rev=37691&r1=37690&r2=37691&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/Delivery.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/Delivery.py [utf8] Wed Aug 11 12:02:22 2010
@@ -801,7 +801,7 @@ class Delivery(XMLObject, Immobilisation
           # indexing. The only exception is the simulation state.
           # I think, if each simulation movement remembers the previous
           # state, we can avoid unnecessary reindexing.
-          my_applied_rule.recursiveReindexObject(activate_kw=activate_kw)
+          my_applied_rule.recursiveReindexSimulationMovement(activate_kw=activate_kw)
         else:
           LOG("ERP5", PROBLEM,
               "Could not expand applied rule %s for delivery %s" %\
@@ -836,8 +836,8 @@ class Delivery(XMLObject, Immobilisation
           if parent_value not in to_expand_list:
             to_expand_list.append(parent_value)
       for rule in to_expand_list:
-        rule.expand(activate_kw=activate_kw,**kw)
-        rule.recursiveReindexObject(activate_kw=activate_kw)
+        rule.expand(activate_kw=activate_kw, **kw)
+        rule.recursiveReindexSimulationMovement(activate_kw=activate_kw)
 
     security.declareProtected( Permissions.AccessContentsInformation,
                                'getRootCausalityValueList')




More information about the Erp5-report mailing list