Module: check_mk
Branch: master
Commit: 5ba6759155cb94903474f7bae6dcff54d4163cf6
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5ba6759155cb94…
Author: Kenneth Okoh <ko(a)mathias-kettner.de>
Date: Tue Oct 23 10:37:42 2018 +0200
Moved page handler registrations to respective mode definitions
Change-Id: I0d87a5a46da08c5ae21f31aa570323b08d35821a
---
cmk/gui/wato/__init__.py | 26 ++++++--------------------
cmk/gui/wato/pages/activate_changes.py | 5 +++--
cmk/gui/wato/pages/automation.py | 5 +++++
cmk/gui/wato/pages/folders.py | 5 +++++
cmk/gui/wato/pages/services.py | 3 +++
5 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/cmk/gui/wato/__init__.py b/cmk/gui/wato/__init__.py
index 9d7162d..59cfc5f 100644
--- a/cmk/gui/wato/__init__.py
+++ b/cmk/gui/wato/__init__.py
@@ -618,7 +618,6 @@ class AgentOutputPage(object):
return "%s-%s-%s.txt" % (site_id, host_name, ty)
-
class PageFetchAgentOutput(AgentOutputPage):
def page(self):
html.header(_("%s: Download agent output") % self._host.name(),
@@ -668,6 +667,9 @@ class PageFetchAgentOutput(AgentOutputPage):
job_manager = gui_background_job.GUIBackgroundJobManager()
job_manager.show_job_details_from_snapshot(job_snapshot=job_snapshot)
+# TODO: Clean this up! We would like to use the cmk.gui.pages.register() decorator
instead
+# of this
+cmk.gui.pages.register_page_handler("fetch_agent_output", lambda:
PageFetchAgentOutput().page())
@gui_background_job.job_registry.register
@@ -710,7 +712,6 @@ class FetchAgentOutputBackgroundJob(WatoBackgroundJob):
job_interface.send_result_message(_("%s Finished.") % button)
-
class PageDownloadAgentOutput(AgentOutputPage):
def page(self):
file_name = self.file_name(self._host.site_id(), self._host.name(), self._ty)
@@ -721,6 +722,9 @@ class PageDownloadAgentOutput(AgentOutputPage):
preview_filepath = os.path.join(self._job.get_work_dir(), file_name)
html.write(file(preview_filepath).read())
+cmk.gui.pages.register_page_handler("download_agent_output", lambda:
PageDownloadAgentOutput().page())
+
+
#.
# .--Network Scan--------------------------------------------------------.
# | _ _ _ _ ____ |
@@ -1189,21 +1193,3 @@ def load_plugins(force):
# exceptions all the time and not only the first time (when the plugins
# are loaded).
loaded_with_language = cmk.gui.i18n.get_current_language()
-
-
-# TODO: Clean this up! We would like to use the cmk.gui.pages.register() decorator
instead
-# of this
-_wato_pages = {
- "ajax_start_activation" : lambda:
ModeAjaxStartActivation().handle_page(),
- "ajax_activation_state" : lambda:
ModeAjaxActivationState().handle_page(),
-
- "automation_login" : lambda: ModeAutomationLogin().page(),
- "noauth:automation" : lambda: ModeAutomation().page(),
- "ajax_set_foldertree" : lambda:
ModeAjaxSetFoldertree().handle_page(),
- "wato_ajax_execute_check" : lambda:
ModeAjaxExecuteCheck().handle_page(),
- "fetch_agent_output" : lambda: PageFetchAgentOutput().page(),
- "download_agent_output" : lambda: PageDownloadAgentOutput().page(),
- "ajax_popup_move_to_folder" : lambda: ModeAjaxPopupMoveToFolder().page(),
-}
-for path, page_func in _wato_pages.items():
- cmk.gui.pages.register_page_handler(path, page_func)
diff --git a/cmk/gui/wato/pages/activate_changes.py
b/cmk/gui/wato/pages/activate_changes.py
index df06972..402f7c4 100644
--- a/cmk/gui/wato/pages/activate_changes.py
+++ b/cmk/gui/wato/pages/activate_changes.py
@@ -43,6 +43,7 @@ from cmk.gui.plugins.wato.utils.base_modes import WatoMode,
WatoWebApiMode
from cmk.gui.plugins.wato.utils.html_elements import wato_styles
from cmk.gui.plugins.wato.utils.context_buttons import home_button
+from cmk.gui.pages import register_page_handler
from cmk.gui.display_options import display_options
from cmk.gui.globals import html
from cmk.gui.i18n import _
@@ -432,7 +433,6 @@ class ModeActivateChanges(WatoMode, watolib.ActivateChanges):
table.end()
-
class ModeAjaxStartActivation(WatoWebApiMode):
def page(self):
watolib.init_wato_datastructures(with_wato_lock=True)
@@ -466,7 +466,7 @@ class ModeAjaxStartActivation(WatoWebApiMode):
"activation_id": activation_id,
}
-
+register_page_handler("ajax_start_activation", lambda:
ModeAjaxStartActivation().handle_page())
class ModeAjaxActivationState(WatoWebApiMode):
@@ -487,6 +487,7 @@ class ModeAjaxActivationState(WatoWebApiMode):
return manager.get_state()
+register_page_handler("ajax_activation_state", lambda:
ModeAjaxActivationState().handle_page())
def do_activate_changes_automation():
diff --git a/cmk/gui/wato/pages/automation.py b/cmk/gui/wato/pages/automation.py
index 0f9d8bf..154b85a 100644
--- a/cmk/gui/wato/pages/automation.py
+++ b/cmk/gui/wato/pages/automation.py
@@ -33,6 +33,7 @@ import cmk.gui.config as config
import cmk.gui.watolib as watolib
import cmk.gui.userdb as userdb
+from cmk.gui.pages import register_page_handler
from cmk.gui.plugins.wato.utils.base_modes import WatoWebApiMode
from cmk.gui.log import logger
from cmk.gui.globals import html
@@ -53,6 +54,8 @@ class ModeAutomationLogin(WatoWebApiMode):
html.set_output_format("python")
html.write_html(repr(watolib.get_login_secret(True)))
+register_page_handler("automation_login", lambda:
ModeAutomationLogin().page())
+
class ModeAutomation(WatoWebApiMode):
"""Executes the requested automation call
@@ -168,3 +171,5 @@ class ModeAutomation(WatoWebApiMode):
raise
html.write_text(_("Internal automation error: %s\n%s") % \
(e, traceback.format_exc()))
+
+register_page_handler("noauth:automation", lambda: ModeAutomation().page())
diff --git a/cmk/gui/wato/pages/folders.py b/cmk/gui/wato/pages/folders.py
index 903c9fd..9a663af 100644
--- a/cmk/gui/wato/pages/folders.py
+++ b/cmk/gui/wato/pages/folders.py
@@ -43,6 +43,7 @@ from cmk.gui.plugins.wato.utils.html_elements import wato_confirm
from cmk.gui.plugins.wato.utils.main_menu import MainMenu, MenuItem
from cmk.gui.plugins.wato.utils.context_buttons import folder_status_button,
global_buttons
+from cmk.gui.pages import register_page_handler
from cmk.gui.globals import html
from cmk.gui.htmllib import HTML
from cmk.gui.i18n import _
@@ -763,6 +764,8 @@ class ModeAjaxPopupMoveToFolder(WatoWebApiMode):
return choices
+register_page_handler("ajax_popup_move_to_folder", lambda:
ModeAjaxPopupMoveToFolder().page())
+
class FolderMode(WatoMode):
__metaclass__ = abc.ABCMeta
@@ -913,3 +916,5 @@ class ModeAjaxSetFoldertree(WatoWebApiMode):
def page(self):
request = self.webapi_request()
config.user.save_file("foldertree", (request.get('topic'),
request.get('target')))
+
+register_page_handler("ajax_set_foldertree", lambda:
ModeAjaxSetFoldertree().handle_page())
diff --git a/cmk/gui/wato/pages/services.py b/cmk/gui/wato/pages/services.py
index 7169664..46f0973 100644
--- a/cmk/gui/wato/pages/services.py
+++ b/cmk/gui/wato/pages/services.py
@@ -40,6 +40,7 @@ from cmk.gui.plugins.wato.utils import mode_registry, may_edit_ruleset
from cmk.gui.plugins.wato.utils.base_modes import WatoMode, WatoWebApiMode
from cmk.gui.plugins.wato.utils.context_buttons import host_status_button,
global_buttons
+from cmk.gui.pages import register_page_handler
from cmk.gui.globals import html
from cmk.gui.i18n import _
from cmk.gui.exceptions import MKGeneralException
@@ -837,3 +838,5 @@ class ModeAjaxExecuteCheck(WatoWebApiMode):
"state_name" : short_service_state_name(state, "UNKN"),
"output" : output,
}
+
+register_page_handler("wato_ajax_execute_check", lambda:
ModeAjaxExecuteCheck().handle_page())