Commit a38c1884 authored by Nicolas Dumazet's avatar Nicolas Dumazet

invert condition and win one indentation level


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42721 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e14aabd8
...@@ -257,61 +257,63 @@ class InteractionWorkflowDefinition (DCWorkflowDefinition, ActiveObject): ...@@ -257,61 +257,63 @@ 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 \ if (tdef.portal_type_filter is not None and \
ob.getPortalType() in tdef.portal_type_filter): ob.getPortalType() not in tdef.portal_type_filter):
# Initialize variables continue
former_status = self._getStatusOf(ob)
econtext = None # Initialize variables
sci = None former_status = self._getStatusOf(ob)
econtext = None
# Update variables. sci = None
tdef_exprs = tdef.var_exprs
if tdef_exprs is None: tdef_exprs = {} # Update variables.
status = {} tdef_exprs = tdef.var_exprs
for id, vdef in self.variables.items(): if tdef_exprs is None: tdef_exprs = {}
if not vdef.for_status: status = {}
continue for id, vdef in self.variables.items():
expr = None if not vdef.for_status:
if tdef_exprs.has_key(id): continue
expr = tdef_exprs[id] expr = None
elif not vdef.update_always and former_status.has_key(id): if tdef_exprs.has_key(id):
# Preserve former value expr = tdef_exprs[id]
value = former_status[id] elif not vdef.update_always and former_status.has_key(id):
# Preserve former value
value = former_status[id]
else:
if vdef.default_expr is not None:
expr = vdef.default_expr
else: else:
if vdef.default_expr is not None: value = vdef.default_value
expr = vdef.default_expr if expr is not None:
else: # Evaluate an expression.
value = vdef.default_value if econtext is None:
if expr is not None: # Lazily create the expression context.
# Evaluate an expression. if sci is None:
if econtext is None: sci = StateChangeInfo(
# Lazily create the expression context. ob, self, former_status, tdef,
if sci is None: None, None, None)
sci = StateChangeInfo( econtext = createExprContext(sci)
ob, self, former_status, tdef, value = expr(econtext)
None, None, None) status[id] = value
econtext = createExprContext(sci)
value = expr(econtext)
status[id] = value
sci = StateChangeInfo(
ob, self, former_status, tdef, None, None, kwargs=kw)
# Execute the "after" script.
for script_name in tdef.after_script_name:
script = self.scripts[script_name]
# Pass lots of info to the script in a single parameter.
script(sci) # May throw an exception
# Execute Before Commit sci = StateChangeInfo(
for script_name in tdef.before_commit_script_name: ob, self, former_status, tdef, None, None, kwargs=kw)
transaction.get().addBeforeCommitHook(self._before_commit, # Execute the "after" script.
(sci, script_name)) for script_name in tdef.after_script_name:
script = self.scripts[script_name]
# Execute "activity" scripts # Pass lots of info to the script in a single parameter.
for script_name in tdef.activate_script_name: script(sci) # May throw an exception
self.activate(activity='SQLQueue')\
.activeScript(script_name, ob.getRelativeUrl(), # Execute Before Commit
status, tdef.id) for script_name in tdef.before_commit_script_name:
transaction.get().addBeforeCommitHook(self._before_commit,
(sci, script_name))
# Execute "activity" scripts
for script_name in tdef.activate_script_name:
self.activate(activity='SQLQueue')\
.activeScript(script_name, ob.getRelativeUrl(),
status, tdef.id)
def _before_commit(self, sci, script_name): def _before_commit(self, sci, script_name):
# check the object still exists before calling the script # check the object still exists before calling the script
......
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