The smallest atom of edgy.workflow is a Transition, which basically is a regular python callable with additional metadata to make the system aware of when it can be applied.

class edgy.workflow.Transition(handler=None, name=None, source=None, target=None)[source]

Defines when and how to go from one state to another, eventually applying a user-defined side-effect while being applied.


>>> t = Transition(name='sleep', source='awake', target='asleep')

>>> class Person(object):
...     state = 'awake'

>>> me = Person()
>>> t(me)
>>> me.state

This class can also be used as a decorator:

>>> @Transition(source='asleep', target='awake')

>>> def wakeup(self, subject):
...     print('HEY!')

>>> wakeup(me)
>>> me.state

A special wildcard source can make transitions work from any state. Just specify “*” as a transition source and you’ll be able to transition from any state.