summaryrefslogtreecommitdiff
path: root/examples/statemachine/documentSignoffDemo.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/statemachine/documentSignoffDemo.py')
-rw-r--r--examples/statemachine/documentSignoffDemo.py21
1 files changed, 3 insertions, 18 deletions
diff --git a/examples/statemachine/documentSignoffDemo.py b/examples/statemachine/documentSignoffDemo.py
index 58aa208..0cbfc1f 100644
--- a/examples/statemachine/documentSignoffDemo.py
+++ b/examples/statemachine/documentSignoffDemo.py
@@ -7,26 +7,11 @@
import statemachine
import documentsignoffstate
+print('\n'.join(t.__name__ for t in documentsignoffstate.DocumentRevisionState.transitions()))
-class Document:
+class Document(documentsignoffstate.DocumentRevisionStateMixin):
def __init__(self):
- # start light in Red state
- self._state = documentsignoffstate.New()
-
- @property
- def state(self):
- return self._state
-
- # get behavior/properties from current state
- def __getattr__(self, attrname):
- attr = getattr(self._state, attrname)
- if isinstance(getattr(documentsignoffstate, attrname, None),
- documentsignoffstate.DocumentRevisionStateTransition):
- return lambda : setattr(self, '_state', attr())
- return attr
-
- def __str__(self):
- return "{0}: {1}".format(self.__class__.__name__, self._state)
+ self.initialize_state(documentsignoffstate.New())
def run_demo():