A library implementing workflows (or state machines) for Python projects.
Project description
XWorkflows is a library to add workflows, or state machines, to Python objects.
It 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', 'bar', '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() # If a method has the name of a transition, it is used as its implementation. def foobar(self): return 42 # It is also possible to use another method for a given transition. @transition('gobaz') def blah(self): return 13 >>> o = MyObject() >>> o.state State('foo', 'foo') >>> o.state.is_foo True >>> o.foobar() 42 >>> o.state State('bar', 'bar') >>> o.blah() 13 >>> o.state State('baz', 'baz')
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
xworkflows-0.1.tar.gz
(16.2 kB
view details)
File details
Details for the file xworkflows-0.1.tar.gz
.
File metadata
- Download URL: xworkflows-0.1.tar.gz
- Upload date:
- Size: 16.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9380a5aafa29b5147989bc32962f09f9b72e2225c3abb6771c73e88af1a5bbb3 |
|
MD5 | e416ae35cf846dd12d393d1e34dc578a |
|
BLAKE2b-256 | 7b51cc5a593052e1113ea1255f0bf0f76c0a8078c488ca3ac9649530debdca15 |