I have written a state machine for a pool controller, but I am struggling with something that is noted in the documentation about forcing the on_enter method to fire off when I initialize the model. The documentation says:
"Note that
on_enter_«state name»
callback will not fire when a Machine is first initialized. For example if you have anon_enter_A()
callback defined, and initialize the Machine withinitial='A'
,on_enter_A()
will not be fired until the next time you enter state A. (If you need to make sureon_enter_A()
fires at initialization, you can simply create a dummy initial state and then explicitly callto_A()
inside the__init__
method.)"
But I am not sure where I need to call this out....I create a Class called Pool_Controller
, then create an instance of Pool_Controller
like this
MyController=Pool_Controller
And then I create the state machine like this
machine = Machine(MyController, states=states, transitions, initial='dummy_state')
Where do I need to put the to_initial_state()
to get the dummy_state immediately jump to my initial_state so that on_enter_initial_state
will execute when the model intializes?