From bfd8e66f6d3f6a46a42f2e880dcbd94d9abe51dc Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Sun, 6 Nov 2016 21:10:17 +0800 Subject: webui: websocket.py: Use flattened configs; Change "data" to "keys" * Get the server-side configurations as a flattened one-level dictionary, for easier manipulations. * When get the configurations, specify the requested config options as an Array under the "keys" property (original: "data" property). --- fg21sim/webui/websocket.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fg21sim/webui/websocket.py b/fg21sim/webui/websocket.py index 23a4423..8c2f427 100644 --- a/fg21sim/webui/websocket.py +++ b/fg21sim/webui/websocket.py @@ -196,13 +196,13 @@ class FG21simWSHandler(tornado.websocket.WebSocketHandler): if msg_action == "get": # Get the values of the specified options try: - data, errors = self._get_configs(keys=msg["data"]) + data, errors = self._get_configs(keys=msg["keys"]) response["success"] = True response["data"] = data response["errors"] = errors except KeyError: response["success"] = False - response["error"] = "'data' is missing" + response["error"] = "'keys' is missing" elif msg_action == "set": # Set the values of the specified options try: @@ -278,7 +278,7 @@ class FG21simWSHandler(tornado.websocket.WebSocketHandler): """ if keys is None: # Dump all the configurations - data = self.configs.dump() + data = self.configs.dump(flatten=True) data["userconfig"] = self.configs.userconfig errors = {} else: -- cgit v1.2.2