Module: check_mk
Branch: master
Commit: 1a2b0739eb76d561fd1e4fdd080ad2e7e217502c
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1a2b0739eb76d5…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Feb 7 11:59:33 2019 +0100
Extracted datasource construction for easier testing
Change-Id: I3c82a11bc443c4996b86bb3be272be8480987559
---
cmk/gui/views.py | 30 +++++++++++++++++-------------
1 file changed, 17 insertions(+), 13 deletions(-)
diff --git a/cmk/gui/views.py b/cmk/gui/views.py
index 0d3c706..af11af4 100644
--- a/cmk/gui/views.py
+++ b/cmk/gui/views.py
@@ -946,19 +946,7 @@ def show_view(view,
show_checkboxes = force_checkboxes or html.request.var('show_checkboxes',
'0') == '1'
# Get the datasource (i.e. the logical table)
- try:
- datasource = data_source_registry[view["datasource"]]()
- except KeyError:
- if view["datasource"].startswith("mkeventd_"):
- raise MKUserError(
- None,
- _("The Event Console view '%s' can not be rendered. The
Event Console is possibly "
- "disabled.") % view["name"])
- else:
- raise MKUserError(
- None,
- _("The view '%s' using the datasource '%s' can not
be rendered "
- "because the datasource does not exist.") %
(view["name"], view["datasource"]))
+ datasource = _get_datasource(view)
tablename = datasource.table
@@ -1175,6 +1163,22 @@ def show_view(view,
show_checkboxes, layout, num_columns, show_filters, show_footer,
browser_reload)
+def _get_datasource(view):
+ try:
+ return data_source_registry[view["datasource"]]()
+ except KeyError:
+ if view["datasource"].startswith("mkeventd_"):
+ raise MKUserError(
+ None,
+ _("The Event Console view '%s' can not be rendered. The
Event Console is possibly "
+ "disabled.") % view["name"])
+ else:
+ raise MKUserError(
+ None,
+ _("The view '%s' using the datasource '%s' can not
be rendered "
+ "because the datasource does not exist.") %
(view["name"], view["datasource"]))
+
+
SorterEntry = namedtuple("SorterEntry", ["sorter",
"negate", "join_key"])