FSM for Feed

This commit is contained in:
Stephen Diehl
2012-06-11 09:26:48 -04:00
parent 087de66e4c
commit fefca77fe2
6 changed files with 53 additions and 30 deletions
+20
View File
@@ -568,3 +568,23 @@ class Component(object):
pid = os.getpid() ,
pointer = hex(id(self)) ,
)
@property
def state(self):
if not hasattr(self, '_state'):
self._state = self.initial_state
else:
return self._state
@state.setter
def state(self, new):
if not hasattr(self, '_state'):
self._state = self.initial_state
old = self._state
if (old, new) in self.workflow:
self._state = new
else:
raise RuntimeError("Invalid State Transition : %s -> %s" %(old, new))