mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 23:41:33 +00:00
Implement FSMUpdates to EventHandlers
This commit is contained in:
parent
b785b88af6
commit
de8c2ae6e2
@ -43,6 +43,7 @@ class TFWServer:
|
|||||||
self._fsm_manager.trigger(trigger, message)
|
self._fsm_manager.trigger(trigger, message)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
LOG.debug('FSM failed to execute nonexistent trigger: "%s"', trigger)
|
LOG.debug('FSM failed to execute nonexistent trigger: "%s"', trigger)
|
||||||
|
message['FSMUpdate'] = self._fsm_updater.get_fsm_state_and_transitions()
|
||||||
return message
|
return message
|
||||||
|
|
||||||
def proxy_filter(self, message):
|
def proxy_filter(self, message):
|
||||||
@ -95,7 +96,10 @@ class FSMUpdater:
|
|||||||
|
|
||||||
def generate_fsm_update(self):
|
def generate_fsm_update(self):
|
||||||
key = 'FSMUpdate'
|
key = 'FSMUpdate'
|
||||||
response = {'data': {'current_state': self.fsm.state,
|
response = {'data': self.get_fsm_state_and_transitions()}
|
||||||
'valid_transitions':
|
|
||||||
[{'trigger': trigger} for trigger in self.fsm.machine.get_triggers(self.fsm.state)]}}
|
|
||||||
return key, response
|
return key, response
|
||||||
|
|
||||||
|
def get_fsm_state_and_transitions(self):
|
||||||
|
state = self.fsm.state
|
||||||
|
valid_transitions = [{'trigger': trigger} for trigger in self.fsm.machine.get_triggers(self.fsm.state)]
|
||||||
|
return {'current_state': state, 'valid_transitions': valid_transitions}
|
||||||
|
Loading…
Reference in New Issue
Block a user