Stateful objects¶
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.
-
class
edgy.workflow.
StatefulObject
[source]¶ Example stateful object.
To use it, subclass me and set the workflow attribute to a
edgy.workflow.Workflow
instance.-
workflow
¶ A workflow instance, setting the system in which the instances of this object live.
-
initial_state
¶ The default initial state of this object.
-
current_state
¶ The current state of this object.
-
state
¶ Helper for getting the actual state of an object. You should use this instead of
initial_state
andcurrent_state
if 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 callinstance.wakeup()
).
-