Module: check_mk
Branch: master
Commit: daa764ecad40170b7f5f765824d06c8ae52df2a3
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=daa764ecad4017…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Oct 10 10:26:00 2016 +0200
Slightly cleaned up user file saving code
---
web/htdocs/config.py | 5 ++---
web/htdocs/weblib.py | 7 ++-----
2 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/web/htdocs/config.py b/web/htdocs/config.py
index 3d8b331..879aab1 100644
--- a/web/htdocs/config.py
+++ b/web/htdocs/config.py
@@ -569,9 +569,8 @@ def user_may(user_id, pname):
# TODO: Check all calls for arguments (changed optional user to 3rd positional)
def save_user_file(name, data, user, unlock=False):
- dirname = config_dir + "/" + user.encode("utf-8")
- make_nagios_directory(dirname)
- path = dirname + "/" + name + ".mk"
+ path = config_dir + "/" + user.encode("utf-8") + "/" +
name + ".mk"
+ make_nagios_directory(os.path.dirname(path))
store.save_data_to_file(path, data)
diff --git a/web/htdocs/weblib.py b/web/htdocs/weblib.py
index a4fb170..50b5868 100644
--- a/web/htdocs/weblib.py
+++ b/web/htdocs/weblib.py
@@ -96,7 +96,7 @@ def get_rowselection(ident):
return vo.get(ident, [])
def set_rowselection(ident, rows, action):
- vo = config.user.load_file("rowselection/%s" % selection_id(), {}, True)
+ vo = config.user.load_file("rowselection/%s" % selection_id(), {},
lock=True)
if action == 'set':
vo[ident] = rows
@@ -110,10 +110,7 @@ def set_rowselection(ident, rows, action):
elif action == 'unset':
del vo[ident]
- if not os.path.exists(config.user.confdir + '/rowselection'):
- make_nagios_directory(config.user.confdir + '/rowselection')
-
- config.user.save_file("rowselection/%s" % selection_id(), vo, True)
+ config.user.save_file("rowselection/%s" % selection_id(), vo, unlock=True)
def ajax_set_rowselection():
ident = html.var('id')