For now, a “stateful object” is, to this library, anything that as a “state” attribute that can be read. If it quacks, then it’s a duck.
However, as an helper class to demonstrate how a workflow can be bound to an object, we provide
StatefulObject as an example implementation that you can use.
Example stateful object.
To use it, subclass me and set the workflow attribute to a
A workflow instance, setting the system in which the instances of this object live.
The default initial state of this object.
The current state of this object.
Helper for getting the actual state of an object. You should use this instead of
current_stateif your only aim is to read or write a new state to this object.
Beware though, the setter of this property will override the state, without going through the transitions. If you wanna run the transitions (and in 95% of the cases, you should, otherwise this library is a pretty bad choice for you), then a proxy attribute exist on the object for each transition name, and you should just call it (for example, if a transition is named
wakeup, you can just call