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
Pipeline #19878 failed with stage
in 0 seconds
......@@ -144,12 +144,24 @@ class InteractionWorkflowDefinition (DCWorkflowDefinition, ActiveObject):
security.declarePrivate('activeScript')
def activeScript(self, script_name, ob_url, status, tdef_id):
script = self.scripts[script_name]
ob = self.unrestrictedTraverse(ob_url)
tdef = self.interactions.get(tdef_id)
sci = StateChangeInfo(
ob, self, status, tdef, None, None, None)
script(sci)
# BBB for when an upgrade to callInterationScript still has unexecuted
# activeScript activities leftover from the previous code.
self.callInterationScript(
script_name=script_name,
ob=self.unrestrictedTraverse(ob_url),
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):
# This check can be implemented with a guard expression, but
......
......@@ -1653,6 +1653,29 @@ class Base(
"""
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,
'getDocumentInstance')
def getDocumentInstance(self):
......
......@@ -285,8 +285,12 @@ class InteractionWorkflow(Workflow):
# Execute "activity" scripts
for script in tdef.getActivateScriptValueList():
self.activate(activity='SQLQueue').activeScript(
script.getId(), ob.getRelativeUrl(), status, tdef.getId())
ob.activate(activity='SQLQueue').activeInteractionScript(
interaction_workflow_path=self.getPhysicalPath(),
script_name=script.getId(),
status=status,
tdef_id=tdef.getId(),
)
def _before_commit(self, sci, script_name, security_manager):
# check the object still exists before calling the script
......@@ -307,11 +311,24 @@ class InteractionWorkflow(Workflow):
security.declarePrivate('activeScript')
def activeScript(self, script_name, ob_url, status, tdef_id):
ob = self.unrestrictedTraverse(ob_url)
tdef = self.getTransitionValueByReference(tdef_id)
sci = StateChangeInfo(
ob, self, status, tdef, None, None, None)
self._getOb(script_name)(sci)
# BBB for when an upgrade to callInterationScript still has unexecuted
# activeScript activities leftover from the previous code.
self.callInterationScript(
script_name=script_name,
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')
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