Module: check_mk
Branch: master
Commit: f9b4feaf6a5d22d4028ac876ddd0691987876184
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f9b4feaf6a5d22…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Jul 12 22:13:34 2018 +0200
Dropped the automatically available html variable
Previously the current html object was available to all GUI code via
the __builtin__ namespace while processing a request. This was tool
friendly and has been replaced with this mechanism. We have a proxy object
which forwards all requests to the html() object of the current request.
Each module that needs the html object for e.g. rendering html code
needs to use the import "from cmk.gui.globals import html" first.
Change-Id: Id590d42bc0a8a27defeb6bad2619c6f0dd00bdb8
---
cmk/gui/globals.py | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++
tests/pylint/pylintrc | 4 ----
web/app/index.wsgi | 15 ++++++++-----
3 files changed, 70 insertions(+), 9 deletions(-)
diff --git a/cmk/gui/globals.py b/cmk/gui/globals.py
new file mode 100644
index 0000000..9a8218d
--- /dev/null
+++ b/cmk/gui/globals.py
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2014 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# tails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+# Previously the current html object was available to all GUI code via the
+# __builtin__ namespace while processing a request. This was tool friendly
+# and has been replaced with this mechanism. We have a proxy object which
+# forwards all requests to the html() object of the current request.
+
+class HTMLProxy(object):
+ def __init__(self):
+ super(HTMLProxy, self).__init__()
+ self._current_html = None
+
+
+ def set_current(self, obj):
+ self._current_html = obj
+
+
+ def unset_current(self):
+ self._current_html = None
+
+
+ def __getattribute__(self, name):
+ if name == "set_current" or name == "unset_current" or name == "_current_html":
+ return object.__getattribute__(self, name)
+
+ h = self._current_html
+ if h is None:
+ raise AttributeError("Not in html context")
+ return getattr(h, name)
+
+
+ def __repr__(self):
+ return repr(self._current_html)
+
+
+html = HTMLProxy()
diff --git a/tests/pylint/pylintrc b/tests/pylint/pylintrc
index 7537c78..497e046 100644
--- a/tests/pylint/pylintrc
+++ b/tests/pylint/pylintrc
@@ -105,7 +105,3 @@ msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg}
[FORMAT]
max-line-length=100
-
-[VARIABLES]
-# Needed by web code because of super globals. TODO Clean this up some day
-additional-builtins=html
diff --git a/web/app/index.wsgi b/web/app/index.wsgi
index d4f3b87..dcd4605 100644
--- a/web/app/index.wsgi
+++ b/web/app/index.wsgi
@@ -32,8 +32,10 @@ import traceback
import livestatus
+import cmk.paths
+import cmk.store as store
+
import cmk.gui.i18n
-from cmk.gui.i18n import _
import cmk.gui.sites as sites
import cmk.gui.config as config
import cmk.gui.modules as modules
@@ -41,12 +43,13 @@ import cmk.gui.pages as pages
import cmk.gui.userdb as userdb
import cmk.gui.login as login
import cmk.gui.log as log
-from cmk.gui.log import logger
import cmk.gui.htmllib
import cmk.gui.http
import cmk.gui.http_status
-import cmk.paths
-import cmk.store as store
+import cmk.gui.globals
+from cmk.gui.log import logger
+from cmk.gui.i18n import _
+from cmk.gui.globals import html
from cmk.gui.exceptions import (
MKUserError,
@@ -68,7 +71,8 @@ class Application(object):
# Create an object that contains all data about the request and
# helper functions for creating valid HTML. Parse URI and
# store results in the request object for later usage.
- __builtin__.html = cmk.gui.htmllib.html(self._request, self._response)
+ h = cmk.gui.htmllib.html(self._request, self._response)
+ cmk.gui.globals.html.set_current(h)
self._process_request()
@@ -149,6 +153,7 @@ class Application(object):
userdb.finalize()
sites.disconnect()
html.finalize()
+ cmk.gui.globals.html.unset_current()
def _handle_request(self):
Module: check_mk
Branch: master
Commit: 80cf7e23f738ca2d15ccc5898d2b0fa2d5f8e815
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=80cf7e23f738ca…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Mon Jul 16 09:29:40 2018 +0200
Attempted fix/workaround for background job problem (untested).
Change-Id: I6476258791b95ca373b968724a97e9c478d87fe5
---
cmk/gui/gui_background_job.py | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/cmk/gui/gui_background_job.py b/cmk/gui/gui_background_job.py
index 12b8534..c4b2e12 100644
--- a/cmk/gui/gui_background_job.py
+++ b/cmk/gui/gui_background_job.py
@@ -150,6 +150,9 @@ class GUIBackgroundJobSnapshottedFunctions(background_job.BackgroundJob):
+# TODO: The superclasses are nonsense: GUIBackgroundJobSnapshottedFunctions
+# already derives from background_jobs.BackgroundJob. What is the right way to
+# fix this?
class GUIBackgroundJob(GUIBackgroundJobSnapshottedFunctions, background_job.BackgroundJob):
_background_process_class = GUIBackgroundProcess
@@ -193,14 +196,16 @@ class GUIBackgroundJob(GUIBackgroundJobSnapshottedFunctions, background_job.Back
# Provides the frozen state of a background job
# Quite helpful when generating GUI pages with several phases
+
+# TODO: What on earth is this class supposed to do?
class GUIBackgroundStatusSnapshot(object):
def __init__(self, background_job):
super(GUIBackgroundStatusSnapshot, self).__init__()
self._job_status = background_job.get_status()
self._logger = background_job._logger.getChild("snapshot")
- for name, value in GUIBackgroundJobSnapshottedFunctions.__dict__.iteritems():
- if hasattr(value, "__call__"):
+ for name in dir(GUIBackgroundJobSnapshottedFunctions):
+ if callable(getattr(GUIBackgroundJobSnapshottedFunctions, name)):
self._job_status[name] = getattr(background_job, name)()
Module: check_mk
Branch: master
Commit: 464e03f18554714a83274bf78c25004e419cfbba
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=464e03f1855471…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Jul 13 13:45:35 2018 +0200
6346 FIX Fixed failed host rename when host is configured as parent on folder level
During host rename an error "TypeError: not all arguments converted during string formatting" could
occur. This happened when the host was configured in at least one folder as parent.
In such a situation the host was renamed partially. The best way to recover from this situation
is to activate all pending changes and use the renaming feature again to change the host back
to it's original name. Then update to at least 1.5.0b9 and try renaming the host again.
Change-Id: If4581639053ba5eecf2b7f3b876756649bbf8437
---
.werks/6346 | 16 ++++++++++++++++
cmk/gui/watolib.py | 4 ++--
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/.werks/6346 b/.werks/6346
new file mode 100644
index 0000000..50b7741
--- /dev/null
+++ b/.werks/6346
@@ -0,0 +1,16 @@
+Title: Fixed failed host rename when host is configured as parent on folder level
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1531482119
+
+During host rename an error "TypeError: not all arguments converted during string formatting" could
+occur. This happened when the host was configured in at least one folder as parent.
+
+In such a situation the host was renamed partially. The best way to recover from this situation
+is to activate all pending changes and use the renaming feature again to change the host back
+to it's original name. Then update to at least 1.5.0b9 and try renaming the host again.
diff --git a/cmk/gui/watolib.py b/cmk/gui/watolib.py
index 65ffe51..f4aed4d 100644
--- a/cmk/gui/watolib.py
+++ b/cmk/gui/watolib.py
@@ -2398,8 +2398,8 @@ class CREFolder(BaseFolder):
if not changed:
return False
- add_change("rename-parent", _("Renamed parent (set in folder) from %s to %s") %
- (self.path(), oldname, newname),
+ add_change("rename-parent", _("Renamed parent from %s to %s in folder \"%s\"") %
+ (oldname, newname, self.alias_path()),
obj=self, sites=self.all_site_ids())
self.save_hosts()
self.save()