Module: check_mk
Branch: master
Commit: 47c4260509bb0a8b2aeeb26d0d46e94946f1762b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=47c4260509bb0a…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Thu Jan 3 13:02:52 2019 +0100
Plugging is always balanced now.
Change-Id: If5872d6e8ad810ad93fb8223f8e67301eef3e9fd
---
cmk/gui/htmllib.py | 27 ++++-----------------------
web/app/index.wsgi | 4 ----
2 files changed, 4 insertions(+), 27 deletions(-)
diff --git a/cmk/gui/htmllib.py b/cmk/gui/htmllib.py
index 775b7cb..8e5da06 100644
--- a/cmk/gui/htmllib.py
+++ b/cmk/gui/htmllib.py
@@ -400,21 +400,15 @@ class OutputFunnel(object):
def _lowlevel_write(self, text):
raise NotImplementedError()
- # TODO: Only use this and make plug()/unplug() private methods.
@contextmanager
def plugged(self):
- self.plug()
+ self.plug_text.append([])
try:
yield
- except Exception:
- self.drain()
- raise
finally:
- self.unplug()
-
- # Put in a plug which stops the text stream and redirects it to a sink.
- def plug(self):
- self.plug_text.append([])
+ text = self.drain()
+ self.plug_text.pop()
+ self.write(text)
def _is_plugged(self):
return bool(self.plug_text)
@@ -428,19 +422,6 @@ class OutputFunnel(object):
self.plug_text.append([])
return text
- def unplug(self):
- if not self._is_plugged(): # TODO: Raise exception or even remove
"if"?
- return
-
- text = self.drain()
- self.plug_text.pop()
- self.write(text)
-
- # TODO: Nuke this when we use plugged() exclusively.
- def unplug_all(self):
- while self._is_plugged():
- self.unplug()
-
#.
# .--HTML Generator------------------------------------------------------.
diff --git a/web/app/index.wsgi b/web/app/index.wsgi
index 89e1d44..43d73e5 100644
--- a/web/app/index.wsgi
+++ b/web/app/index.wsgi
@@ -109,9 +109,6 @@ class Application(object):
livestatus.MKLivestatusException,
), e:
# TODO: Refactor all the special cases handled here to simplify the exception
handling
-
- html.unplug_all()
-
ty = type(e)
if ty == livestatus.MKLivestatusNotFoundError:
title = _("Data not found")
@@ -141,7 +138,6 @@ class Application(object):
logger.error(_("%s: %s") % (plain_title, e))
except Exception, e:
- html.unplug_all()
logger.exception()
if self._plain_error():
html.set_output_format("text")