API

class viewflow.fsm.TransitionNotAllowed

Exception raised when a state transition is not permitted.

class viewflow.fsm.State(states: Any, default: Any | None = None)

State slot field.

@transition(self, source: Any, target: Any | None = None, label: str | None = None, conditions: List[ThisObject | Callable[[object, object], bool]] | None = None, permission: ThisObject | Callable[[object, Any], bool] | None = None) Any

Decorator to mark a method as a state transition.

ANY

alias of ANY

class CONDITION(is_true: bool, unmet: str = '')

Boolean-like object to return value accompanied with a message from fsm conditions.

class viewflow.fsm.FlowAdminMixin

A Mixin for providing Finite State Machine (FSM) management support in Django admin.

viewflow.fsm.chart(flow_state: StateDescriptor, exclude_guards=True)

Draws a directed graph (digraph) of the state transitions defined in the given flow_state.

Args:
flow_state (StateDescriptor): The state descriptor object. exclude_guards (bool): Whether to exclude transitions with no target state.
Returns:
str: A string representation of the digraph in the DOT language.

The function uses the flow_state object to extract the transitions and the states involved. It then generates a DOT language string, which can be used with tools like Graphviz to produce an image of the graph.

Note that the function ignores the State.USE_RETURN_VALUE and State.SELECT states for now, as these are not supported yet.