Module: check_mk
Branch: master
Commit: f8fc67a9b12814d2a95d9dd592c873dbad35ef90
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f8fc67a9b12814…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Jan 20 10:04:09 2015 +0100
#1870 FIX Joined columns were empty in CSV, JSON or PYTHON exports of view
Joined view columns did not work correctly in CSV, JSON or PYTHON output formats.
The columns were simply empty, while the regular columns on the web page were
showing information.
---
.werks/1870 | 12 ++++++++++++
ChangeLog | 1 +
web/htdocs/views.py | 37 +++++++++++++++++++++----------------
web/plugins/views/webservice.py | 6 +++---
4 files changed, 37 insertions(+), 19 deletions(-)
diff --git a/.werks/1870 b/.werks/1870
new file mode 100644
index 0000000..0601321
--- /dev/null
+++ b/.werks/1870
@@ -0,0 +1,12 @@
+Title: Joined columns were empty in CSV, JSON or PYTHON exports of view
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1421744582
+
+Joined view columns did not work correctly in CSV, JSON or PYTHON output formats.
+The columns were simply empty, while the regular columns on the web page were
+showing information.
diff --git a/ChangeLog b/ChangeLog
index 60489fa..1cd78f9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -110,6 +110,7 @@
* 1803 FIX: Fixed exception in Check_MK prediction page...
* 1804 FIX: Fixed prechecked checkboxes in view actions after first action submit...
* 1843 FIX: Fixed crash in display of crash report for precompiled host checks
+ * 1870 FIX: Joined columns were empty in CSV, JSON or PYTHON exports of view...
WATO:
* 1760 Added search form to manual checks page
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index 628ba15..744f96e 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -2008,23 +2008,37 @@ def execute_hooks(hook):
else:
pass
-def paint_painter(painter, row):
+def paint(p, row, tdattrs=""):
+ tdclass, content = prepare_paint(p, row)
+
+ if tdclass:
+ html.write("<td %s class=\"%s\">%s</td>\n" %
(tdattrs, tdclass, content))
+ else:
+ html.write("<td %s>%s</td>" % (tdattrs, content))
+ return content != ""
+
+def paint_painter(painter, row, join_key=None):
+ if join_key != None:
+ row = row.get("JOIN", {}).get(join_key)
+ if not row:
+ return "", "" # no join information available for that
column
+
if "args" in painter:
return painter["paint"](row, *painter["args"])
else:
return painter["paint"](row)
+def get_join_key(p):
+ return len(p) >= 4 and p[3] or None
+
def prepare_paint(p, row):
painter = p[0]
linkview = p[1]
tooltip = len(p) > 2 and p[2] or None
- if len(p) >= 4:
- join_key = p[3]
- row = row.get("JOIN", {}).get(p[3])
- if not row:
- return "", "" # no join information available for that
column
- tdclass, content = paint_painter(painter, row)
+ tdclass, content = paint_painter(painter, row, join_key=get_join_key(p))
+ if tdclass == "" and content == "":
+ return tdclass, content
content = html.utf8_to_entities(content)
@@ -2082,15 +2096,6 @@ def row_id(view, row):
key += '~%s' % row[col]
return str(hash(key))
-def paint(p, row, tdattrs=""):
- tdclass, content = prepare_paint(p, row)
-
- if tdclass:
- html.write("<td %s class=\"%s\">%s</td>\n" %
(tdattrs, tdclass, content))
- else:
- html.write("<td %s>%s</td>" % (tdattrs, content))
- return content != ""
-
def paint_stalified(row, text):
if is_stale(row):
return "stale", text
diff --git a/web/plugins/views/webservice.py b/web/plugins/views/webservice.py
index 71c0bf8..f7e49a7 100644
--- a/web/plugins/views/webservice.py
+++ b/web/plugins/views/webservice.py
@@ -41,7 +41,7 @@ def render_python(rows, view, group_painters, painters, num_columns,
show_checkb
for row in rows:
html.write("[")
for p in painters:
- tdclass, content = p[0]["paint"](row)
+ tdclass, content = paint_painter(p[0], row, join_key=get_join_key(p))
html.write(repr(html.strip_tags(content)))
html.write(",")
html.write("],")
@@ -94,7 +94,7 @@ def render_json(rows, view, group_painters, painters, num_columns,
show_checkbox
first = False
else:
html.write(",")
- tdclass, content = paint_painter(p[0], row)
+ tdclass, content = paint_painter(p[0], row, join_key=get_join_key(p))
if type(content) == unicode:
content = content.encode("utf-8")
else:
@@ -161,7 +161,7 @@ def render_csv(rows, view, group_painters, painters, num_columns,
show_checkboxe
first = False
else:
html.write(csv_separator)
- tdclass, content = paint_painter(p[0], row)
+ tdclass, content = paint_painter(p[0], row, join_key=get_join_key(p))
content = type(content) in [ int, float ] and str(content) or content
stripped = html.strip_tags(content).replace('\n',
'').replace('"', '""')
html.write('"%s"' % stripped.encode("utf-8"))