Commit 2142fee1 authored by Nicolas Dumazet's avatar Nicolas Dumazet

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.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42726 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ef56caad
...@@ -219,17 +219,15 @@ class InteractionWorkflowDefinition (DCWorkflowDefinition, ActiveObject): ...@@ -219,17 +219,15 @@ class InteractionWorkflowDefinition (DCWorkflowDefinition, ActiveObject):
for t_id in transition_list: for t_id in transition_list:
tdef = self.interactions[t_id] tdef = self.interactions[t_id]
assert tdef.trigger_type == TRIGGER_WORKFLOW_METHOD assert tdef.trigger_type == TRIGGER_WORKFLOW_METHOD
if (tdef.portal_type_filter is None or \ filtered_transition_list.append(tdef.id)
ob.getPortalType() in tdef.portal_type_filter): former_status = self._getStatusOf(ob)
filtered_transition_list.append(tdef.id) # Execute the "before" script.
former_status = self._getStatusOf(ob) for script_name in tdef.script_name:
# Execute the "before" script. script = self.scripts[script_name]
for script_name in tdef.script_name: # Pass lots of info to the script in a single parameter.
script = self.scripts[script_name] sci = StateChangeInfo(
# Pass lots of info to the script in a single parameter. ob, self, former_status, tdef, None, None, kwargs=kw)
sci = StateChangeInfo( script(sci) # May throw an exception
ob, self, former_status, tdef, None, None, kwargs=kw)
script(sci) # May throw an exception
return filtered_transition_list return filtered_transition_list
...@@ -248,9 +246,6 @@ class InteractionWorkflowDefinition (DCWorkflowDefinition, ActiveObject): ...@@ -248,9 +246,6 @@ class InteractionWorkflowDefinition (DCWorkflowDefinition, ActiveObject):
for t_id in transition_list: for t_id in transition_list:
tdef = self.interactions[t_id] tdef = self.interactions[t_id]
assert tdef.trigger_type == TRIGGER_WORKFLOW_METHOD 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 # Initialize variables
former_status = self._getStatusOf(ob) former_status = self._getStatusOf(ob)
......
...@@ -709,7 +709,9 @@ def initializePortalTypeDynamicWorkflowMethods(self, klass, ptype, prop_holder, ...@@ -709,7 +709,9 @@ def initializePortalTypeDynamicWorkflowMethods(self, klass, ptype, prop_holder,
for wf_id, v in interaction_workflow_dict.iteritems(): for wf_id, v in interaction_workflow_dict.iteritems():
transition_id_set, trigger_dict = v transition_id_set, trigger_dict = v
for tr_id, tdef in trigger_dict.iteritems(): 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: for imethod_id in tdef.method_id:
if wildcard_interaction_method_id_match(imethod_id): if wildcard_interaction_method_id_match(imethod_id):
# Interactions workflows can use regexp based wildcard methods # Interactions workflows can use regexp based wildcard methods
......
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