Commit a4ffa1a7 authored by Vincent Pelletier's avatar Vincent Pelletier

ERP5{,Type.Core}.InteractionWorkflow: Deprecate activeScript.

Replace it with a method on ERP5Type.Base so these activities get found
by CopySupport.unindexObject and flushed, rather than remaining on the
interaction workflow's context and failing when run.
It seems a lot more likely for a document to be deleted while interactions
are being spawned than an interaction workflow itself. So this should be
a net benefit in activity stability.
parent 95db27a8
...@@ -144,12 +144,24 @@ class InteractionWorkflowDefinition (DCWorkflowDefinition, ActiveObject): ...@@ -144,12 +144,24 @@ class InteractionWorkflowDefinition (DCWorkflowDefinition, ActiveObject):
security.declarePrivate('activeScript') security.declarePrivate('activeScript')
def activeScript(self, script_name, ob_url, status, tdef_id): def activeScript(self, script_name, ob_url, status, tdef_id):
script = self.scripts[script_name] # BBB for when an upgrade to callInterationScript still has unexecuted
ob = self.unrestrictedTraverse(ob_url) # activeScript activities leftover from the previous code.
tdef = self.interactions.get(tdef_id) self.callInterationScript(
sci = StateChangeInfo( script_name=script_name,
ob, self, status, tdef, None, None, None) ob=self.unrestrictedTraverse(ob_url),
script(sci) status=status,
tdef_id=tdef_id,
)
security.declarePrivate('callInterationScript')
def callInterationScript(self, script_name, ob, status, tdef_id):
self.scripts[script_name](
StateChangeInfo(
ob, self, status,
self.interactions.get(tdef_id),
None, None, None,
),
)
def _checkTransitionGuard(self, t, ob, **kw): def _checkTransitionGuard(self, t, ob, **kw):
# This check can be implemented with a guard expression, but # This check can be implemented with a guard expression, but
......
...@@ -1653,6 +1653,29 @@ class Base( ...@@ -1653,6 +1653,29 @@ class Base(
""" """
return self return self
security.declarePrivate('activeInteractionScript')
def activeInteractionScript(
self,
interaction_workflow_path,
script_name,
status,
tdef_id,
):
"""
Call interaction script on current document.
This is defined on the document involved in the interaction so that
CopySupport.unindexObject can find the activities involving this method
and flush them.
"""
self.getPortalObject().unrestrictedTraverse(
interaction_workflow_path,
).callInterationScript(
script_name=script_name,
ob=self,
status=status,
tdef_id=tdef_id,
)
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'getDocumentInstance') 'getDocumentInstance')
def getDocumentInstance(self): def getDocumentInstance(self):
......
...@@ -285,8 +285,12 @@ class InteractionWorkflow(Workflow): ...@@ -285,8 +285,12 @@ class InteractionWorkflow(Workflow):
# Execute "activity" scripts # Execute "activity" scripts
for script in tdef.getActivateScriptValueList(): for script in tdef.getActivateScriptValueList():
self.activate(activity='SQLQueue').activeScript( ob.activate(activity='SQLQueue').activeInteractionScript(
script.getId(), ob.getRelativeUrl(), status, tdef.getId()) interaction_workflow_path=self.getPhysicalPath(),
script_name=script.getId(),
status=status,
tdef_id=tdef.getId(),
)
def _before_commit(self, sci, script_name, security_manager): def _before_commit(self, sci, script_name, security_manager):
# check the object still exists before calling the script # check the object still exists before calling the script
...@@ -307,11 +311,24 @@ class InteractionWorkflow(Workflow): ...@@ -307,11 +311,24 @@ class InteractionWorkflow(Workflow):
security.declarePrivate('activeScript') security.declarePrivate('activeScript')
def activeScript(self, script_name, ob_url, status, tdef_id): def activeScript(self, script_name, ob_url, status, tdef_id):
ob = self.unrestrictedTraverse(ob_url) # BBB for when an upgrade to callInterationScript still has unexecuted
tdef = self.getTransitionValueByReference(tdef_id) # activeScript activities leftover from the previous code.
sci = StateChangeInfo( self.callInterationScript(
ob, self, status, tdef, None, None, None) script_name=script_name,
self._getOb(script_name)(sci) ob=self.unrestrictedTraverse(ob_url),
status=status,
tdef_id=tdef_id,
)
security.declarePrivate('callInterationScript')
def callInterationScript(self, script_name, ob, status, tdef_id):
self._getOb(script_name)(
StateChangeInfo(
ob, self, status,
self.getTransitionValueByReference(tdef_id),
None, None, None,
),
)
security.declarePrivate('isActionSupported') security.declarePrivate('isActionSupported')
def isActionSupported(self, ob, action, **kw): def isActionSupported(self, ob, action, **kw):
......
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