mirror of
https://github.com/wassname/catalyst.git
synced 2026-10-02 12:10:23 +08:00
FSM for Feed
This commit is contained in:
1 parent
087de66e4c
commit
fefca77fe2
6 files changed
+53
-30
No files matched your search
@@ -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))
|
||||
Reference in new issue
Block a user