Module: check_mk
Branch: master
Commit: ae3be96addda0f62bb5fe3a93ba605884a069a3e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ae3be96addda0f…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Thu Jan 3 15:11:16 2019 +0100
Fixed a TODO. Tiny simplification and cleanup.
Change-Id: I2ca6674686b951444402c06e13ad135e81341f37
---
cmk/gui/exceptions.py | 19 +++++++------------
cmk/gui/login.py | 3 ++-
web/app/index.wsgi | 4 ++--
3 files changed, 11 insertions(+), 15 deletions(-)
diff --git a/cmk/gui/exceptions.py b/cmk/gui/exceptions.py
index b2e81ad..fb9406b 100644
--- a/cmk/gui/exceptions.py
+++ b/cmk/gui/exceptions.py
@@ -43,24 +43,19 @@ class RequestTimeout(MKTimeout):
class FinalizeRequest(Exception):
"""Is used to end the HTTP request processing from deeper code
levels"""
- # TODO: Drop this default and make exit code explicit for all call sites
- def __init__(self, code=None):
- # type: (Optional[int]) -> None
- self.status = code or httplib.OK
- super(FinalizeRequest,
- self).__init__("%d %s" % (self.status,
HTTP_STATUS_CODES[self.status]))
+ def __init__(self, code):
+ # type: (int) -> None
+ super(FinalizeRequest, self).__init__("%d %s" % (code,
HTTP_STATUS_CODES[code]))
+ self.status = code
class HTTPRedirect(FinalizeRequest):
"""Is used to end the HTTP request processing from deeper code levels
and making the client request another page after receiving the
response."""
- def __init__(self, url, code=httplib.FOUND):
- # type: (str, int) -> None
- super(HTTPRedirect, self).__init__(code)
- if code not in [httplib.MOVED_PERMANENTLY, httplib.FOUND]:
- raise Exception("Invalid status code: %d" % code)
-
+ def __init__(self, url):
+ # type: (str) -> None
+ super(HTTPRedirect, self).__init__(httplib.FOUND)
self.url = url #type: str
diff --git a/cmk/gui/login.py b/cmk/gui/login.py
index 563867f..22f4daa 100644
--- a/cmk/gui/login.py
+++ b/cmk/gui/login.py
@@ -24,6 +24,7 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
+import httplib
import os
import time
import traceback
@@ -530,7 +531,7 @@ def page_logout():
html.response.set_http_header(
'WWW-Authenticate', 'Basic realm="OMD Monitoring Site
%s"' % config.omd_site())
html.response.set_cookie('logout', '1')
- raise FinalizeRequest(401)
+ raise FinalizeRequest(httplib.UNAUTHORIZED)
else:
html.response.del_cookie('logout')
html.response.http_redirect(config.url_prefix() + 'check_mk/')
diff --git a/web/app/index.wsgi b/web/app/index.wsgi
index 6ae66a0..501a72f 100644
--- a/web/app/index.wsgi
+++ b/web/app/index.wsgi
@@ -190,7 +190,7 @@ class Application(object):
handler()
except Exception, e:
self._show_exception_info(e)
- raise FinalizeRequest()
+ raise FinalizeRequest(httplib.OK)
# Ensure the user is authenticated. This call is wrapping all the different
# authentication modes the Check_MK GUI supports and initializes the logged
@@ -231,7 +231,7 @@ class Application(object):
# requested page is performed.
login.page_login(self._plain_error())
- raise FinalizeRequest()
+ raise FinalizeRequest(httplib.OK)
def _localize_request(self):
previous_language = cmk.gui.i18n.get_current_language()