Activation¶
- class viewflow.activation.Activation(*args, **kwargs)¶
Base class for flow task activations.
Activation is responsible for flow task state management and persistance.
Each activation status changes are restricted by a simple finite state automata.
Base class ensures that all tasks can be undone or cancelled.
- classmethod activate(flow_task, prev_activation, token)¶
Instantiate and persist new flow task.
- cancel¶
Cancel existing task.
- exception_guard()¶
Perform activation action inside a transaction.
Handle and propagate exception depending on activation context state.
- get_available_transitions()¶
List of all available activation transitions.
- get_status()¶
Get the status of the activated task.
- initialize¶
Initialize the activation instance.
- set_status(value)¶
Set the status to the underline task.
- undo¶
Undo the task.
If flow class has [task_name]_undo(self, activation) method, it will be called.
- class viewflow.activation.StartActivation(*args, **kwargs)¶
Bases:
viewflow.activation.Activation
Base class for task activations that creates new process instance.
- activate_next¶
Activate all outgoing edges.
- done¶
Create and start new process instance.
See also
See also
See also
- has_perm(user)¶
Check user permission to execute the task.
- initialize¶
Initialize an activation.
- prepare¶
Initialize start task for execution.
No db changes performed. It is safe to call it on GET requests.
- undo¶
Undo the task.
- class viewflow.activation.ViewActivation(*args, **kwargs)¶
Bases:
viewflow.activation.Activation
Base class for activations for django views tasks.
- classmethod activate(flow_task, prev_activation, token)¶
Instantiate new task.
- activate_next¶
Activate all outgoing edges.
- assign¶
Assign user to the task.
- classmethod create_task(flow_task, prev_activation, token)¶
Create a task instance.
- done¶
Mark task as finished.
See also
See also
- has_perm(user)¶
Check user permission to execute the task.
- prepare¶
Initialize start task for execution.
No db changes performed. It is safe to call it on GET requests.
- reassign¶
Reassign to another user.
- unassign¶
Remove user from the task assignment.
- undo¶
Undo the task.
- class viewflow.activation.EndActivation(*args, **kwargs)¶
Bases:
viewflow.activation.Activation
Activation that finishes the flow process.
- classmethod activate(flow_task, prev_activation, token)¶
Mark process as done, and cancel all other active tasks.
- perform¶
Finalize the flow. If there is no active task, process marked as finished.
See also
See also
See also
- undo¶
Undo the task.
Background job¶
- class viewflow.activation.AbstractJobActivation(*args, **kwargs)¶
Bases:
viewflow.activation.Activation
Base class for background script tasks.
- classmethod activate(flow_task, prev_activation, token)¶
Activate and schedule for background job execution.
It is safe to schedule job just now b/c the process instance is locked, and job will wait until this transaction completes.
- activate_next¶
Activate all outgoing edges.
- assign¶
Assign scheduled background task id.
- cancel¶
Cancel existing task.
- done¶
Mark task as done.
See also
- error¶
Mark task as failed.
See also
- restart¶
Restart the task excecution after error.
- retry¶
Put the task into schedule again.
- run_async()¶
Run task asynchronously.
Subclasses should override that method.
- schedule¶
Schedule task for execution.
- start¶
Mark task as started.
See also
- undo¶
Undo the task.
Function tasks¶
- class viewflow.activation.FuncActivation(*args, **kwargs)¶
Bases:
viewflow.activation.Activation
Function activate.
- classmethod activate(flow_task, prev_activation, token)¶
Instantiate new task.
- activate_next¶
Activate all outgoing edges.
- done¶
Should be the last call in the function.
- prepare¶
Set the task.started time.
- class viewflow.nodes.handler.HandlerActivation(*args, **kwargs)¶
Bases:
viewflow.activation.Activation
Handler Activation.
Executes a callback immediately.
- classmethod activate(flow_task, prev_activation, token)¶
Instantiate new task.
- activate_next¶
Activate all outgoing edges.
- execute()¶
Run the callback.
- perform¶
Perform the callback within current exception propagation strategy.
- retry¶
Retry the next node calculation and activation.
- undo¶
Undo the task.
Gates¶
- class viewflow.activation.AbstractGateActivation(*args, **kwargs)¶
Bases:
viewflow.activation.Activation
Base class for flow gates activation.
- classmethod activate(flow_task, prev_activation, token)¶
Activate and schedule for background job execution.
It is safe to schedule job just now b/c the process instance is locked, and job will wait until this transaction completes.
- activate_next¶
Activate next tasks.
- calculate_next()¶
Calculate next tasks for activation.
- perform¶
Calculate the next node and activate it.
See also
See also
See also
- retry¶
Retry the next node calculation and activation.
- undo¶
Undo the task.
- class viewflow.nodes.ifgate.IfActivation(**kwargs)¶
Bases:
viewflow.activation.AbstractGateActivation
Conditionally activate one of outgoing nodes.
- activate_next¶
Conditionally activate one of outgoing nodes.
- calculate_next()¶
Calculate node to activate.
- class viewflow.nodes.join.JoinActivation(**kwargs)¶
Bases:
viewflow.activation.Activation
Activation for parallel Join node.
- classmethod activate(flow_task, prev_activation, token)¶
Join and if all incoming path completed, continue execution.
Join task is created on the first activation. Subsequent activations would lookup for the Join Task instance.
- activate_next¶
Activate all outgoing edges.
- cancel¶
Cancel existing join.
- done¶
Complete the join within current exception propagation strategy.
- is_done()¶
Check that process can be continued futher.
Join check the all task state in db with the common token prefix.
Join node would continue execution if all incoming tasks are DONE or CANCELED.
- perform¶
Manual gateway activation.
- retry¶
Manual join gateway reactivation after an error.
- start¶
Create Join task on the first incoming node complete.
- undo¶
Undo the task.
- class viewflow.nodes.split.SplitActivation(**kwargs)¶
Bases:
viewflow.activation.AbstractGateActivation
Parallel split gateway activation.
- activate_next¶
Activate next tasks for parallel execution.
Each task would have a new execution token attached, the Split task token as a common prefix.
- calculate_next()¶
Calculate nodes list to activate.
- class viewflow.nodes.switch.SwitchActivation(**kwargs)¶
Bases:
viewflow.activation.AbstractGateActivation
Switch gateway activation.
- activate_next¶
Activate calculated node.
- calculate_next()¶
Calculate node to activate.