Module: check_mk
Branch: master
Commit: 753d9cd4a2ab461921302c14e54b5333b73cfb56
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=753d9cd4a2ab46…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Mar 11 09:52:56 2016 +0100
Fixed mixup between SearchFolder and Folder logic in single method
---
web/htdocs/watolib.py | 49 +++++++++++++++++++++++++++++++------------------
1 file changed, 31 insertions(+), 18 deletions(-)
diff --git a/web/htdocs/watolib.py b/web/htdocs/watolib.py
index b3bc60c..b6536f0 100644
--- a/web/htdocs/watolib.py
+++ b/web/htdocs/watolib.py
@@ -625,26 +625,23 @@ class Folder(BaseFolder):
# latter case we need to load all hosts in all folders and actively search the host.
@staticmethod
def current():
- if not html.is_cached("wato_current_folder"):
- if html.has_var("host_search"):
- base_folder = Folder.folder(html.var("folder", ""))
- search_criteria = SearchFolder.criteria_from_html_vars()
- folder = SearchFolder(base_folder, search_criteria)
- elif html.has_var("folder"):
- folder = Folder.folder(html.var("folder"))
- else:
- host_name = html.var("host")
- if host_name: # find host with full scan. Expensive operation
- host = Host.host(host_name)
- if host:
- folder = host.folder()
- else:
- folder = Folder.root_folder()
- html.set_cache("wato_current_folder", folder)
- return folder
- else:
+ if html.is_cached("wato_current_folder"):
return html.get_cached("wato_current_folder")
+ if html.has_var("folder"):
+ folder = Folder.folder(html.var("folder"))
+ else:
+ host_name = html.var("host")
+ if host_name: # find host with full scan. Expensive operation
+ host = Host.host(host_name)
+ if host:
+ folder = host.folder()
+ else:
+ folder = Folder.root_folder()
+
+ Folder.set_current(folder)
+ return folder
+
@staticmethod
def current_disk_folder():
@@ -1709,6 +1706,22 @@ class SearchFolder(BaseFolder):
return crit
+ @staticmethod
+ def current():
+ if html.is_cached("wato_current_folder"):
+ return html.get_cached("wato_current_folder")
+
+ if html.has_var("host_search"):
+ base_folder = Folder.folder(html.var("folder", ""))
+ search_criteria = SearchFolder.criteria_from_html_vars()
+ folder = SearchFolder(base_folder, search_criteria)
+ Folder.set_current(folder)
+ return
+ else:
+ # FIXME: Is this needed for SearchFolder()?
+ return Folder.current()
+
+
# .--------------------------------------------------------------------.
# | CONSTRUCTION |
# '--------------------------------------------------------------------'