aboutsummaryrefslogtreecommitdiffstats
path: root/fg21sim/configs/manager.py
diff options
context:
space:
mode:
authorAaron LI <aaronly.me@outlook.com>2016-11-22 09:34:05 +0800
committerAaron LI <aaronly.me@outlook.com>2016-11-22 09:34:05 +0800
commitb542121fa90041ea457dd605feaca7077a8f6bc4 (patch)
tree2ac49bd844c75061bc7599f59db9c277b3d7503b /fg21sim/configs/manager.py
parent4d7072d5b15c7bb2a2260c4f1566950f6220fb38 (diff)
downloadfg21sim-b542121fa90041ea457dd605feaca7077a8f6bc4.tar.bz2
webui: configs: Some minor fixes
* configs.py/_set_configs(): Also return the original data if the input values failed the validation; * setServerConfigs(): Success callback also reset value if the input value failed pass the server-side validation; * getServerConfigs(): Return "undefined" if key does not exists.
Diffstat (limited to 'fg21sim/configs/manager.py')
-rw-r--r--fg21sim/configs/manager.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/fg21sim/configs/manager.py b/fg21sim/configs/manager.py
index 5cf9b00..7818d1c 100644
--- a/fg21sim/configs/manager.py
+++ b/fg21sim/configs/manager.py
@@ -344,7 +344,7 @@ class ConfigManager:
def setn(self, key, value):
"""Set the value of config option specified by a list of keys or a
- "sep"-separated keys string.
+ "/"-separated keys string.
The supplied key-value config pair is first used to create a
temporary ``ConfigObj`` instance, which is then validated against
@@ -379,10 +379,9 @@ class ConfigManager:
ConfigError :
The value fails to pass the validation against specifications.
"""
- try:
- val_old = self.getn(key)
- except KeyError as e:
- raise KeyError(e)
+ # NOTE:
+ # May raise ``KeyError`` if the key does not exists
+ val_old = self.getn(key)
if val_old == value:
# No need to set this option value
return
@@ -396,6 +395,8 @@ class ConfigManager:
# Create the temporary ``ConfigObj`` instance and validate it
config_new = ConfigObj(d, interpolation=False,
configspec=self._configspec)
+ # NOTE:
+ # May raise ``ConfigError`` if fails to pass the validation
config_new = self._validate(config_new)
# NOTE:
# The validated ``config_new`` is populated with all other options