Of course feel free to do it differently and submit a patch that folks
(myself and others) can review.

-Josh
Kwan, Louie wrote:

https://github.com/openstack/automaton
Friendly state machines for python.
A few questions about automaton.
1.I would like to know can we addition parameters on on_enter or on_exit
callbacks. Right now, it seems it only allows state and triggered_event.
a.I have many FSM running for different objects and it is much easier if
I can pass on the some sort of ID back to the callbacks.
2.Can we or how can we store extra attribute like last state change
*timestamp*?
3.Can we store additional identify info for the FSM object? Would like
to add an */UUID/*
Thanks.
Louie
def print_on_enter(new_state, triggered_event):
print("Entered '%s' due to '%s'" % (new_state, triggered_event))
def print_on_exit(old_state, triggered_event):
print("Exiting '%s' due to '%s'" % (old_state, triggered_event))
# This will contain all the states and transitions that our machine will
# allow, the format is relatively simple and designed to be easy to use.
state_space = [
{
'name': 'stopped',
'next_states': {
# On event 'play' transition to the 'playing' state.
'play': 'playing',
'open_close': 'opened',
'stop': 'stopped',
},
'on_enter': print_on_enter,
'on_exit': print_on_exit,
},
__________________________________________________________________________
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev