Delete a setting properly

This commit is contained in:
Kload 2013-12-05 10:39:36 +00:00
parent 3da8cb3537
commit e52e5187e1
2 changed files with 7 additions and 2 deletions

View file

@ -334,6 +334,10 @@ app:
-v: -v:
full: --value full: --value
help: Value to set help: Value to set
-d:
full: --delete
help: Delete the key
action: store_true
### app_checkport() ### app_checkport()
checkport: checkport:

View file

@ -544,7 +544,7 @@ def app_removeaccess(apps, users):
app_ssowatconf() app_ssowatconf()
def app_setting(app, key, value=None): def app_setting(app, key, value=None, delete=False):
""" """
Set ou get an app setting value Set ou get an app setting value
@ -552,6 +552,7 @@ def app_setting(app, key, value=None):
value -- Value to set value -- Value to set
app -- App ID app -- App ID
key -- Key to get/set key -- Key to get/set
delete -- Delete the key
""" """
settings_file = apps_setting_path + app +'/settings.yml' settings_file = apps_setting_path + app +'/settings.yml'
@ -571,7 +572,7 @@ def app_setting(app, key, value=None):
# Set the value # Set the value
if app_settings is None: if app_settings is None:
app_settings = {} app_settings = {}
if value == '' and key in app_settings: if delete and key in app_settings:
del app_settings[key] del app_settings[key]
else: else:
app_settings[key] = value app_settings[key] = value