From: hernani Date: Fri, 30 Sep 2011 11:36:17 +0000 (+0000) Subject: Simple method to hold the current request for special cases. X-Git-Tag: live~137 X-Git-Url: https://git.openstreetmap.org./osqa.git/commitdiff_plain/bd65d9583dbb436bbc1a790e7649531742b8386a Simple method to hold the current request for special cases. git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@1180 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- diff --git a/forum/__init__.py b/forum/__init__.py index e69de29..51c0c43 100644 --- a/forum/__init__.py +++ b/forum/__init__.py @@ -0,0 +1,5 @@ +class RequestHolder(object): + def __init__(self): + self.request = None + +REQUEST_HOLDER = RequestHolder() \ No newline at end of file diff --git a/forum/middleware/request_utils.py b/forum/middleware/request_utils.py index e3b5bc2..e90d3c5 100644 --- a/forum/middleware/request_utils.py +++ b/forum/middleware/request_utils.py @@ -1,7 +1,11 @@ +import forum + from forum.settings import MAINTAINANCE_MODE, APP_LOGO, APP_TITLE from forum.http_responses import HttpResponseServiceUnavailable + + class RequestUtils(object): def process_request(self, request): if MAINTAINANCE_MODE.value is not None and isinstance(MAINTAINANCE_MODE.value.get('allow_ips', None), list): @@ -15,4 +19,10 @@ class RequestUtils(object): request.META['REQUEST_METHOD'] = "POST" self.request = request - return None \ No newline at end of file + forum.REQUEST_HOLDER.request = request + return None + + def process_response(selfself, request, response): + forum.REQUEST_HOLDER.request = None + return response +