I'm using Django-viewflow to create a workflow programmatically.
This is my flow class.
class Workflow(Flow):
start = (
flow.StartFunction(function1)
.Next(this.shipment_create)
)
shipment_create = (
flow.Function(function2)
.Next(this.request_quotes)
)
request_quotes = (
flow.Handler(function3)
.Next(this.move_package)
)
move_package = (
flow.Function(function4)
.Next(this.end)
)
end = flow.End()
What I do is, I start the flow programmatically, when a POST request is made onto an endpoint E1, I run
WorkFLow.start.run(**some_kwargs)
It starts correctly, and after the processing of the start
is completed, then the response is returned back to the client.
Now, shipment_create
is run when a POST request is made on endpoint E2, and I run it again programmatically via,
activation.flow_task.run(**some_kwargs)
It runs correctly and completes the flow up-to move_package
.
THE PROBLEM
I update the details of shipment
, via PUT request on endpoint E3, and I want to re-run the complete flow after node shipment_create
. How can I do that?
How can I re-run the flow after a specific node?
Point(1) is a manual step, ie programmatically re-run the after nodes. Is there a way, I can include
shipment_update
node in Workflow class itself so that it automatically re-runs the after-nodes? How and where I would mentionupdate_shipment
node?
The problem I see in point(2) is, in one situation I am declaring shipment_create
node after start (and the rest Handlers will process), and in another situation I've to mention shipment_update
node after start (and the rest Handlers will process). How will the workflow class work according to the type of HTTP method?
Updated
How to return the response of Handler (ie function4
)?
def function1():
return 1
def function2():
return 2
def function3():
return 3
def function4():
return 4
When shipment_create
is run, the Handler is executed automatically. However, the response returned is that of shipment_create
node, ie function2.
How to return the response of function3(Handler)
or How to get the response of the last executed node before sending it back to the client?