diff options
-rw-r--r-- | settings.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/settings.py b/settings.py index 4cd882b..f0c297a 100644 --- a/settings.py +++ b/settings.py @@ -392,7 +392,7 @@ hooks = {} def add_setting_changed_hook(setting, func): - '''Called right before new settings take effect''' + '''Called right after new settings take effect''' if setting in hooks: hooks[setting].append(func) else: @@ -447,15 +447,21 @@ def settings_page(): assert SETTINGS_INFO[setting_name]['type'] is bool, missing_inputs current_settings_dict[setting_name] = False - # call setting hooks + # find settings that have changed to prepare setting hook calls + to_call = [] for setting_name, value in current_settings_dict.items(): old_value = globals()[setting_name] if value != old_value and setting_name in hooks: for func in hooks[setting_name]: - func(old_value, value) + to_call.append((func, old_value, value)) globals().update(current_settings_dict) save_settings(current_settings_dict) + + # call setting hooks + for func, old_value, value in to_call: + func(old_value, value) + return flask.redirect(util.URL_ORIGIN + '/settings', 303) else: flask.abort(400) |