mirror of
https://github.com/status-im/spiff-arena.git
synced 2025-01-30 03:35:31 +00:00
7515519bc9
d9fcd45a Updating release numbers e0d04877 Merge pull request #251 from sartography/bugfix/make-data-objects-available-to-prescripts 7d260c36 Merge pull request #252 from sartography/bug/data_object_serializer_fix 3de54d97 Fixing a failing test. 27c5d3e1 A minor fix during deserialization to avoid issues for some users that upgraded between official releases. 250311d6 copy data objects before prescript execution git-subtree-dir: SpiffWorkflow git-subtree-split: d9fcd45a384f8376a669cf58677564289d2c661c
45 lines
1.6 KiB
Python
45 lines
1.6 KiB
Python
from copy import deepcopy
|
|
|
|
from SpiffWorkflow.task import TaskState
|
|
from SpiffWorkflow.bpmn.specs .BpmnSpecMixin import BpmnSpecMixin
|
|
|
|
class SpiffBpmnTask(BpmnSpecMixin):
|
|
|
|
def __init__(self, wf_spec, name, prescript=None, postscript=None, **kwargs):
|
|
|
|
# WHy am I doing this instead of just calling super?
|
|
# Because I need to deal with multiple inheritance and the kwargs nightmare created by our parser design
|
|
BpmnSpecMixin.__init__(self, wf_spec, name, **kwargs)
|
|
self.prescript = prescript
|
|
self.postscript = postscript
|
|
|
|
@property
|
|
def spec_type(self):
|
|
return 'Spiff BPMN Task'
|
|
|
|
def execute_script(self, my_task, script):
|
|
try:
|
|
my_task.workflow.script_engine.execute(my_task, script)
|
|
except Exception as exc:
|
|
my_task._set_state(TaskState.WAITING)
|
|
raise exc
|
|
|
|
def get_payload(self, my_task, script, expr):
|
|
try:
|
|
data = deepcopy(my_task.data)
|
|
my_task.worklflow.script_engine.execute(my_task, script, data)
|
|
return my_task.workflow.script_engine._evaluate(expr, data)
|
|
except Exception as exc:
|
|
my_task._set_state(TaskState.WAITING)
|
|
raise exc
|
|
|
|
def _on_ready_hook(self, my_task):
|
|
super()._on_ready_hook(my_task)
|
|
if self.prescript is not None:
|
|
self.execute_script(my_task, self.prescript)
|
|
|
|
def _on_complete_hook(self, my_task):
|
|
if self.postscript is not None:
|
|
self.execute_script(my_task, self.postscript)
|
|
super()._on_complete_hook(my_task)
|