Skip to content

Latest commit

 

History

History
136 lines (96 loc) · 2.16 KB

File metadata and controls

136 lines (96 loc) · 2.16 KB

API

StateChart

.. autoclass:: statemachine.statemachine.StateChart
    :members:
    :undoc-members:

StateMachine

.. autoclass:: statemachine.statemachine.StateMachine
    :members:
    :undoc-members:

State

{ref}`States` reference.
.. autoclass:: statemachine.state.State
    :members:

HistoryState

.. autoclass:: statemachine.state.HistoryState
    :members:

States (class)

.. autoclass:: statemachine.states.States
    :noindex:
    :members:

Transition

{ref}`Transitions` reference.
.. autoclass:: statemachine.transition.Transition
    :members:

TransitionList

.. autoclass:: statemachine.transition_list.TransitionList
    :members:

Model

{ref}`Domain models` reference.
.. autoclass:: statemachine.model.Model
    :members:

TriggerData

.. autoclass:: statemachine.event_data.TriggerData
    :members:

Event

.. autoclass:: statemachine.event.Event
    :members: id, name, __call__

EventData

.. autoclass:: statemachine.event_data.EventData
    :members:

Callback conventions

These are convention-based callbacks that you can define on your state machine subclass. They are not methods on the base class — define them in your subclass to enable the behavior.

prepare_event

Called before every event is processed. Returns a dict of keyword arguments that will be merged into **kwargs for all subsequent callbacks (guards, actions, entry/exit handlers) during that event's processing:

class MyMachine(StateMachine):
    initial = State(initial=True)
    loop = initial.to.itself()

    def prepare_event(self):
        return {"request_id": generate_id()}

    def on_loop(self, request_id):
        # request_id is available here
        ...

create_machine_class_from_definition

.. autofunction:: statemachine.io.create_machine_class_from_definition