Commit 8e64841f authored by Yoshinori Okuji's avatar Yoshinori Okuji

Add a special way to disable interactions for temporary documents, as this...

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.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@39043 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e5edf944
......@@ -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
......
......@@ -324,6 +324,19 @@ class InteractionWorkflowDefinition (DCWorkflowDefinition, ActiveObject):
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',
......
......@@ -53,6 +53,11 @@
<td><input type="checkbox" name="once_per_transaction:int" value="1" <dtml-if once_per_transaction>checked</dtml-if>/></td>
</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>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment