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
No related merge requests found
......@@ -219,17 +219,15 @@ class InteractionWorkflowDefinition (DCWorkflowDefinition, ActiveObject):
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 (DCWorkflowDefinition, ActiveObject):
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)
......
......@@ -709,7 +709,9 @@ def initializePortalTypeDynamicWorkflowMethods(self, klass, ptype, prop_holder,
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
......
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