Commit 775bab2d authored by wenjie.zheng's avatar wenjie.zheng

InteractionWorkflow.py: deploy property accessors as many as possible.

parent e8215657
......@@ -140,14 +140,15 @@ class InteractionWorkflow(IdAsReferenceMixin("", "prefix"), Workflow):
getSecurityManager(), self, ob):
return default
status = self._getStatusOf(ob)
default_expr = vdef.getDefaultExpr()
if status is not None and name in status:
value = status[name]
# Not set yet. Use a default.
elif vdef.default_expr is not None:
elif default_expr is not None:
ec = createExprContext(StateChangeInfo(ob, self, status))
value = Expression(vdef.default_expr)(ec)
value = Expression(default_expr)(ec)
else:
value = vdef.default_value
value = vdef.getInitialValue()
return value
......@@ -161,7 +162,7 @@ class InteractionWorkflow(IdAsReferenceMixin("", "prefix"), Workflow):
return tdef is not None and self._checkTransitionGuard(tdef, ob)
def _checkTransitionGuard(self, tdef, document, **kw):
if tdef.temporary_document_disallowed:
if tdef.getTemporaryDocumentDisallowed():
isTempDocument = getattr(document, 'isTempDocument', None)
if isTempDocument is not None:
if isTempDocument():
......@@ -253,7 +254,7 @@ class InteractionWorkflow(IdAsReferenceMixin("", "prefix"), Workflow):
for t_id in transition_list:
tdef = self._getOb('interaction_' + t_id )
assert tdef.trigger_type == TRIGGER_WORKFLOW_METHOD
assert tdef.getTriggerType() == TRIGGER_WORKFLOW_METHOD
filtered_transition_list.append(tdef.getId())
former_status = {}
......@@ -284,7 +285,7 @@ class InteractionWorkflow(IdAsReferenceMixin("", "prefix"), Workflow):
for t_id in transition_list:
tdef = self._getOb('interaction_' + t_id )
assert tdef.trigger_type == TRIGGER_WORKFLOW_METHOD
assert tdef.getTriggerType() == TRIGGER_WORKFLOW_METHOD
former_status = {}
econtext = None
sci = None
......@@ -296,19 +297,20 @@ class InteractionWorkflow(IdAsReferenceMixin("", "prefix"), Workflow):
for vdef in self.objectValues(portal_type='Variable'):
id = vdef.getId()
if not vdef.for_status:
if not vdef.getForStatus():
continue
expr = None
if id in tdef_exprs:
expr = tdef_exprs[id]
elif not vdef.update_always and id in former_status:
elif not vdef.getAutomaticUpdate() and id in former_status:
# Preserve former value
value = former_status[id]
else:
if vdef.default_expr is not None:
expr = vdef.default_expr
default_expr = vdef.getDefaultExpr()
if default_expr is not None:
expr = Expression(default_expr)
else:
value = vdef.default_value
value = vdef.getInitialValue()
if expr is not None:
# Evaluate an expression.
if econtext is None:
......@@ -386,7 +388,7 @@ class InteractionWorkflow(IdAsReferenceMixin("", "prefix"), Workflow):
if action in sdef.getDestinationIdList():
tdef = self._getOb(action, None)
if (tdef is not None and
tdef.trigger_type == TRIGGER_USER_ACTION and
tdef.getTriggerType() == TRIGGER_USER_ACTION and
self._checkTransitionGuard(tdef, document, **kw)):
return 1
return 0
......
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