Skip to content

Instantly share code, notes, and snippets.

@kracekumar kracekumar/

Last active Jul 17, 2016
What would you like to do?
state machine
class Order:
states = ['placed', 'dispatched', 'delivered', 'canceled', 'returned']
transitions = [
# placed
['dispatch', 'placed', 'dispatched'],
['cancel', 'placed', 'canceled'],
# dispatched
['deliver', 'dispatched', 'delivered'],
['cancel', 'dispatched', 'canceled'],
# Returned
['return', 'delivered', 'returned']
from transitions import Machine
machine = Machine(model=Order(), states=states, transitions=transitions, initial='placed', ignore_invalid_triggers=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.