Module: check_mk
Branch: master
Commit: 3b635f13232a4d26e2c77b471c551c9eb6991126
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3b635f13232a4d…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Apr 1 15:41:45 2014 +0200
Yet another fix for the new secure transaction ids
---
web/htdocs/html_mod_python.py | 3 ++-
web/htdocs/htmllib.py | 23 ++++++++++++-----------
2 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/web/htdocs/html_mod_python.py b/web/htdocs/html_mod_python.py
index 5c28a76..b164ad4 100644
--- a/web/htdocs/html_mod_python.py
+++ b/web/htdocs/html_mod_python.py
@@ -151,7 +151,8 @@ class html_mod_python(htmllib.html):
return config.load_user_file("transids", [])
def save_transids(self, used_ids):
- config.save_user_file("transids", used_ids)
+ if config.user_id:
+ config.save_user_file("transids", used_ids)
def save_tree_states(self):
config.save_user_file("treestates", self.treestates)
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index d897b80..ae524a8 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -798,14 +798,14 @@ class html:
self.javascript(self.final_javascript_code)
self.write("</body></html>\n")
+ # Hopefully this is the correct place to performe some "finalization"
tasks.
+ self.store_new_transids()
+
def footer(self):
if self.output_format == "html":
self.bottom_footer()
self.body_end()
- # Hopefully this is the correct place to performe some "finalization"
tasks.
- if self.user:
- self.store_new_transids()
def add_status_icon(self, img, tooltip, url = None):
if url:
@@ -963,16 +963,17 @@ class html:
# time we remove all entries from that list that are older
# than one week.
def store_new_transids(self):
- valid_ids = self.load_transids()
+ if self.new_transids:
+ valid_ids = self.load_transids()
- cleared_ids = []
- now = time.time()
- for valid_id in valid_ids:
- timestamp, rand = valid_id.split("/")
- if now - int(timestamp) < 604800: # 7 * 24 hours
- cleared_ids.append(valid_id)
+ cleared_ids = []
+ now = time.time()
+ for valid_id in valid_ids:
+ timestamp, rand = valid_id.split("/")
+ if now - int(timestamp) < 604800: # 7 * 24 hours
+ cleared_ids.append(valid_id)
- self.save_transids(cleared_ids + self.new_transids)
+ self.save_transids(cleared_ids + self.new_transids)
# Remove the used transid from the list of valid ones
def invalidate_transid(self, used_id):