xworkflowsA library implementing workflows (or state machines) for Python projects | |
Download |
xworkflows Ranking & Summary
Advertisement
- License:
- BSD License
- Price:
- FREE
- Publisher Name:
- Raphael Barrois
- Publisher web site:
- https://github.com/rbarrois/
xworkflows Tags
xworkflows Description
xworkflows is a Python library to add workflows, or state machines, to Python objects.ExampleIt allows to easilly define a workflow, attach it to a class, and use its transitions:class MyWorkflow(xworkflows.Workflow): # A list of state names states = ( ('foo', _(u"Foo")), ('bar', _(u"Bar")), ('baz', _(u"Baz")), ) # A list of transition definitions; items are (name, source states, target). transitions = ( ('foobar', 'foo', 'bar'), ('gobaz', ('foo', 'bar'), 'baz'), ('bazbar', 'baz', 'bar'), ) initial_state = 'foo'class MyObject(xworkflows.WorkflowEnabled): state = MyWorkflow() @transition() def foobar(self): return 42 # It is possible to use another method for a given transition. @transition('gobaz') def blah(self): return 13>>> o = MyObject()>>> o.stateState('foo')>>> o.state.is_fooTrue>>> o.foobar()42>>> o.stateState('bar')>>> o.blah()13>>> o.stateState('baz')Product's homepage
xworkflows Related Software