[Erp5-report] r39043 yo - in /erp5/trunk/products/ERP5: ./ dtml/

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Oct 12 09:41:54 CEST 2010


Author: yo
Date: Tue Oct 12 09:41:47 2010
New Revision: 39043

URL: http://svn.erp5.org?rev=39043&view=rev
Log:
Add a special way to disable interactions for temporary documents, as this pattern is frequently used in many ERP5 applications, and it is a big bottleneck in the performance.

Modified:
    erp5/trunk/products/ERP5/Interaction.py
    erp5/trunk/products/ERP5/InteractionWorkflow.py
    erp5/trunk/products/ERP5/dtml/interaction_properties.dtml

Modified: erp5/trunk/products/ERP5/Interaction.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Interaction.py?rev=39043&r1=39042&r2=39043&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Interaction.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Interaction.py [utf8] Tue Oct 12 09:41:47 2010
@@ -59,6 +59,7 @@ class InteractionDefinition (SimpleItem)
     method_id = ()
     portal_type_filter = None
     once_per_transaction = False
+    temporary_document_disallowed = False
 
     manage_options = (
         {'label': 'Properties', 'action': 'manage_properties'},
@@ -119,6 +120,7 @@ class InteractionDefinition (SimpleItem)
                       portal_type_filter=None,
                       trigger_type=TRIGGER_WORKFLOW_METHOD,
                       once_per_transaction=False,
+                      temporary_document_disallowed=True,
                       script_name=(),
                       after_script_name=(),
                       before_commit_script_name=(),
@@ -149,6 +151,7 @@ class InteractionDefinition (SimpleItem)
         self.description = str(description)
         self.trigger_type = int(trigger_type)
         self.once_per_transaction = bool(once_per_transaction)
+        self.temporary_document_disallowed = bool(temporary_document_disallowed)
         self.script_name = script_name
         self.after_script_name = after_script_name
         self.before_commit_script_name = before_commit_script_name

Modified: erp5/trunk/products/ERP5/InteractionWorkflow.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/InteractionWorkflow.py?rev=39043&r1=39042&r2=39043&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/InteractionWorkflow.py [utf8] (original)
+++ erp5/trunk/products/ERP5/InteractionWorkflow.py [utf8] Tue Oct 12 09:41:47 2010
@@ -324,6 +324,19 @@ class InteractionWorkflowDefinition (DCW
     def _getWorkflowStateOf(self, ob, id_only=0):
           return None
 
+    def _checkTransitionGuard(self, t, ob, **kw):
+        # This check can be implemented with a guard expression, but
+        # it has a lot of overhead to use a TALES, so we make a special
+        # treatment for the frequent case, that is, disallow the trigger
+        # on a temporary document.
+        if t.temporary_document_disallowed:
+            isTempDocument = getattr(ob, 'isTempDocument', None)
+            if isTempDocument is not None:
+                if isTempDocument():
+                    return 0
+
+        return DCWorkflowDefinition._checkTransitionGuard(self, t, ob, **kw)
+
 Globals.InitializeClass(InteractionWorkflowDefinition)
 
 addWorkflowFactory(InteractionWorkflowDefinition, id='interaction_workflow',

Modified: erp5/trunk/products/ERP5/dtml/interaction_properties.dtml
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/dtml/interaction_properties.dtml?rev=39043&r1=39042&r2=39043&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/dtml/interaction_properties.dtml [utf8] (original)
+++ erp5/trunk/products/ERP5/dtml/interaction_properties.dtml [utf8] Tue Oct 12 09:41:47 2010
@@ -54,6 +54,11 @@
 </tr>
 
 <tr>
+<th align="left">Do not trigger on a temporary document</th>
+<td><input type="checkbox" name="temporary_document_disallowed:int" value="1" <dtml-if temporary_document_disallowed>checked</dtml-if>/></td>
+</tr>
+
+<tr>
 <th align="left">Script (before)</th>
 <td>
 <select name="script_name:list" multiple size="5">




More information about the Erp5-report mailing list