menu

Activation

class viewflow.activation.Activation(*args, **kwargs)

Base class for flow task activations.

Activation responsible for flow task state management and persistance

Each activation status chages restricted by a simple finite state automata

Base class enshures that all tasks could be undone or cancelled.

digraph status {
    UNRIPE;
    NEW -> CANCELED [label="cancel"];
    DONE -> NEW [label="undo"];
    {rank = min;NEW}
}
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 depends on actvation context state

get_available_transtions()

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 have [task_name]_undo(self, activation) method it would be called

class viewflow.activation.StartActivation(*args, **kwargs)

Bases: viewflow.activation.Activation

Base class for task activations that creates new process instance.

digraph status {
    UNRIPE;
    DONE -> NEW [label="undo"];
    NEW -> CANCELED [label="cancel"];
    NEW -> PREPARED [label="prepare"]
    PREPARED -> DONE [label="done"]
    {rank = min;NEW}
}
activate_next

Activate all outgoing edges.

done

Create and start new process instance.

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.

digraph status {
    UNRIPE;
    DONE -> DONE [label="activate_next"]
    DONE -> NEW [label="undo"];
    NEW -> ASSIGNED [label="assign"];
    ASSIGNED -> NEW [label="unassign"];
    ASSIGNED -> ASSIGNED [label="reassign"];
    ASSIGNED->PREPARED [label="prepare"];
    PREPARED->DONE [label="done"];
    {rank = min;NEW}
}
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.

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.

digraph status {
    UNRIPE;
    NEW -> CANCELED [label="cancel"];
    DONE -> NEW [label="undo"];
    NEW -> DONE [label="perform"];
    {rank = min;NEW}
}
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.

undo

Undo the task.

Background job

class viewflow.activation.AbstractJobActivation(*args, **kwargs)

Bases: viewflow.activation.Activation

Base class for background script tasks.

digraph status {
    UNRIPE;
    DONE -> DONE [label="activate_next"];
    NEW -> ASSIGNED [label="assign"]
    ASSIGNED -> SCHEDULED [label="schedule"]
    ASSIGNED -> ERROR [label="schedule"]
    SCHEDULED -> STARTED [label="start"]
    STARTED -> DONE [label="done"]
    STARTED -> ERROR [label="error"]
    SCHEDULED -> SCHEDULED [label="retry"]
    STARTED -> SCHEDULED [label="retry"]
    ERROR -> SCHEDULED [label="retry"]
    SCHEDULED -> ERROR [label="retry"]
    STARTED -> ERROR [label="retry"]
    ERROR -> ERROR [label="retry"]
    SCHEDULED -> NEW [label="undo"];
    STARTED -> NEW [label="undo"];
    ERROR -> NEW [label="undo"];
    DONE -> NEW [label="undo"];
    NEW -> CANCELED [label="cancel"];
    ASSIGNED -> CANCELED [label="cancel"];
    {rank = min;NEW}
}
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.

error

Mark task as failed.

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.

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.

digraph status {
    UNRIPE;
    NEW -> CANCELED [label="cancel"];
    DONE -> NEW [label="undo"];
    ERROR -> NEW [label="undo"];
    NEW -> DONE [label="perform"];
    NEW -> ERROR [label="perform"];
    ERROR -> DONE [label="retry"];
    ERROR -> ERROR [label="retry"];
    {rank = min;NEW}
}
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 codes and activates it.

retry

Retry the next node calculation and activation.

undo

Undo the task.

class viewflow.nodes.ifgate.IfActivation(**kwargs)

Bases: viewflow.activation.AbstractGateActivation

Condifinally activate one of outgoing nodes.

activate_next

Condifinally 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.