[Erp5-report] r42726 nicolas.dumazet - in /erp5/trunk/products: ERP5/ ERP5Type/

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Jan 28 08:57:54 CET 2011


Author: nicolas.dumazet
Date: Fri Jan 28 08:57:54 2011
New Revision: 42726

URL: http://svn.erp5.org?rev=42726&view=rev
Log:
Check portal type filters of Interaction Workflows at registration
time instead of runtime.

Since the portal type does not change, and since methods are wrapped
individually depending on the portal type, it is safe to do this at
registration time.

It means that no "useless" interactions are attached to objects,
and that the portal type check only happens once in the life of a method.
Overall, this should contribute to better performances.

Modified:
    erp5/trunk/products/ERP5/InteractionWorkflow.py
    erp5/trunk/products/ERP5Type/Base.py

Modified: erp5/trunk/products/ERP5/InteractionWorkflow.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/InteractionWorkflow.py?rev=42726&r1=42725&r2=42726&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/InteractionWorkflow.py [utf8] (original)
+++ erp5/trunk/products/ERP5/InteractionWorkflow.py [utf8] Fri Jan 28 08:57:54 2011
@@ -219,17 +219,15 @@ class InteractionWorkflowDefinition (DCW
     for t_id in transition_list:
       tdef = self.interactions[t_id]
       assert tdef.trigger_type == TRIGGER_WORKFLOW_METHOD
-      if (tdef.portal_type_filter is None or \
-          ob.getPortalType() in tdef.portal_type_filter):
-        filtered_transition_list.append(tdef.id)
-        former_status = self._getStatusOf(ob)
-        # Execute the "before" script.
-        for script_name in tdef.script_name:
-          script = self.scripts[script_name]
-          # Pass lots of info to the script in a single parameter.
-          sci = StateChangeInfo(
-              ob, self, former_status, tdef, None, None, kwargs=kw)
-          script(sci)  # May throw an exception
+      filtered_transition_list.append(tdef.id)
+      former_status = self._getStatusOf(ob)
+      # Execute the "before" script.
+      for script_name in tdef.script_name:
+        script = self.scripts[script_name]
+        # Pass lots of info to the script in a single parameter.
+        sci = StateChangeInfo(
+            ob, self, former_status, tdef, None, None, kwargs=kw)
+        script(sci)  # May throw an exception
 
     return filtered_transition_list
 
@@ -248,9 +246,6 @@ class InteractionWorkflowDefinition (DCW
     for t_id in transition_list:
       tdef = self.interactions[t_id]
       assert tdef.trigger_type == TRIGGER_WORKFLOW_METHOD
-      if (tdef.portal_type_filter is not None and \
-          ob.getPortalType() not in tdef.portal_type_filter):
-        continue
 
       # Initialize variables
       former_status = self._getStatusOf(ob)

Modified: erp5/trunk/products/ERP5Type/Base.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Base.py?rev=42726&r1=42725&r2=42726&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Base.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Base.py [utf8] Fri Jan 28 08:57:54 2011
@@ -709,7 +709,9 @@ def initializePortalTypeDynamicWorkflowM
   for wf_id, v in interaction_workflow_dict.iteritems():
     transition_id_set, trigger_dict = v
     for tr_id, tdef in trigger_dict.iteritems():
-      # XXX Prefiltering per portal type would be more efficient
+      if (tdef.portal_type_filter is not None and \
+          ptype not in tdef.portal_type_filter):
+        continue
       for imethod_id in tdef.method_id:
         if wildcard_interaction_method_id_match(imethod_id):
           # Interactions workflows can use regexp based wildcard methods



More information about the Erp5-report mailing list