mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 19:01:33 +00:00
Merge pull request #27 from avatao-content/eh-stateupdates
Implement FSMUpdates to EventHandlers
This commit is contained in:
commit
8043338e58
@ -43,6 +43,7 @@ class TFWServer:
|
||||
self._fsm_manager.trigger(trigger, message)
|
||||
except AttributeError:
|
||||
LOG.debug('FSM failed to execute nonexistent trigger: "%s"', trigger)
|
||||
message['FSMUpdate'] = self._fsm_updater.get_fsm_state_and_transitions()
|
||||
return message
|
||||
|
||||
def proxy_filter(self, message):
|
||||
@ -95,7 +96,10 @@ class FSMUpdater:
|
||||
|
||||
def generate_fsm_update(self):
|
||||
key = 'FSMUpdate'
|
||||
response = {'data': {'current_state': self.fsm.state,
|
||||
'valid_transitions':
|
||||
[{'trigger': trigger} for trigger in self.fsm.machine.get_triggers(self.fsm.state)]}}
|
||||
response = {'data': self.get_fsm_state_and_transitions()}
|
||||
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