Commit 724155ba authored by wenjie.zheng's avatar wenjie.zheng Committed by Sebastien Robin

Interaction.py: remove unused functions.

parent 35bc8338
...@@ -41,6 +41,7 @@ from Products.DCWorkflow.Expression import StateChangeInfo ...@@ -41,6 +41,7 @@ from Products.DCWorkflow.Expression import StateChangeInfo
from Products.ERP5Type.id_as_reference import IdAsReferenceMixin from Products.ERP5Type.id_as_reference import IdAsReferenceMixin
class Interaction(IdAsReferenceMixin('interaction_', "prefix"), XMLObject): class Interaction(IdAsReferenceMixin('interaction_', "prefix"), XMLObject):
""" """
An ERP5 Interaction. An ERP5 Interaction.
""" """
...@@ -84,12 +85,6 @@ class Interaction(IdAsReferenceMixin('interaction_', "prefix"), XMLObject): ...@@ -84,12 +85,6 @@ class Interaction(IdAsReferenceMixin('interaction_', "prefix"), XMLObject):
PropertySheet.Interaction, PropertySheet.Interaction,
) )
def _getObjectByRef(self, ref):
for ob in self:
if wf.getRef() == ref:
return ob
return None
def getGuardSummary(self): def getGuardSummary(self):
res = None res = None
if self.guard is not None: if self.guard is not None:
...@@ -128,123 +123,6 @@ class Interaction(IdAsReferenceMixin('interaction_', "prefix"), XMLObject): ...@@ -128,123 +123,6 @@ class Interaction(IdAsReferenceMixin('interaction_', "prefix"), XMLObject):
elif self.guard.expr != self.getExpression(): elif self.guard.expr != self.getExpression():
self.guard.expr = self.getExpression() self.guard.expr = self.getExpression()
def execute(self, ob, form_kw=None):
LOG(' Calling interaction %s'%self.getId(), WARNING, ' in Interaction.py')### getRef
### zwj: What will be done this part
### this part shoud be called in Base.py as transition be called.
# 1: execute before script;
# 2: execute after script;
# 3: Queue before commit script;
# 4: execute activity script.
# Initialize variables
former_status = {}
econtext = None
sci = None
# Figure out the old and new states.
if form_kw is None:
form_kw = {}
workflow = self.getParent()
assert self.trigger_type == TRIGGER_WORKFLOW_METHOD
#status = workflow.getCurrentStatusDict(ob)
sci = StateChangeInfo(
ob, workflow, former_status, self, None, None, kwargs=form_kw)
# Execute before script
before_script_list = []
before_script_list.append(self.getBeforeScriptName())
if before_script_list != [] and self.getBeforeScriptName() is not None:
for script_name in before_script_list:
script = workflow._getOb(script_name) ### _getObjectByRef
# Pass lots of info to the script in a single parameter.
script.execute(sci)
# Update variables.
tdef_exprs = self.var_exprs
if tdef_exprs is None: tdef_exprs = {}
for vdef in workflow.objectValues(portal_type='Variable'):
id = vdef.getId() ### getRef
if not vdef.for_status:
continue
expr = None
if id in tdef_exprs:
expr = tdef_exprs[id]
elif not vdef.update_always and id in former_status:
# Preserve former value
value = former_status[id]
else:
if vdef.default_expr is not None:
expr = vdef.default_expr
else:
value = vdef.default_value
if expr is not None:
# Evaluate an expression.
if econtext is None:
# Lazily create the expression context.
if sci is None:
sci = StateChangeInfo(
ob, workflow, former_status, self,
None, None, None)
econtext = Expression_createExprContext(sci)
value = expr(econtext)
#status[id] = value
# Execute the "after" script.
after_script_list = []
after_script_list.append(self.getAfterScriptName())
if after_script_list != [] and self.getAfterScriptName() is not None:
for script_name in after_script_list:
script = workflow._getOb(script_name) ### getObjectByRef
LOG('Accessing afterscript: %s'%script_name, WARNING, 'in Interaction.py')
# Pass lots of info to the script in a single parameter.
script.execute(sci) # May throw an exception
# Queue the "Before Commit" scripts
sm = getSecurityManager()
before_commit_script_list = []
before_commit_script_list.append(self.getBeforeCommitScriptName())
if before_commit_script_list != [] and self.getBeforeCommitScriptName() is not None:
for script_name in before_commit_script_list:
transaction.get().addBeforeCommitHook(self._before_commit,
(sci, script_name, sm))
# Execute "activity" scripts
activity_script_list = []
activity_script_list.append(self.getActivateScriptName())
if activity_script_list != [] and self.getActivateScriptName() is not None:
for script_name in activity_script_list:
workflow.activate(activity='SQLQueue')\
.activeScript(script_name, ob.getRelativeUrl(),
former_status, self.getId()) ### getRef
def _before_commit(self, sci, script_name, security_manager):
# check the object still exists before calling the script
ob = sci.object
workflow = self.getParent()
while ob.isTempObject():
ob = ob.getParentValue()
if aq_base(self.unrestrictedTraverse(ob.getPhysicalPath(), None)) is \
aq_base(ob):
current_security_manager = getSecurityManager()
try:
# Who knows what happened to the authentication context
# between here and when the interaction was executed... So we
# need to switch to the security manager as it was back then
setSecurityManager(security_manager)
workflow._getOb(script_name)(sci) ### _getObjectByRef
finally:
setSecurityManager(current_security_manager)
def activeScript(self, script_name, ob_url, former_status):
workflow = self.getParent()
script = workflow._getOb(script_name) ### _getObjectByRef
ob = self.unrestrictedTraverse(ob_url)
sci = StateChangeInfo(
ob, worfklow, former_status, self, None, None, kwargs=kw)
script.execute(sci)
def getMethodId(self): def getMethodId(self):
if type(self.method_id) is type(''): if type(self.method_id) is type(''):
self.method_id = self.method_id.split() self.method_id = self.method_id.split()
......
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