aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordyh <dengyuanhong@chinamobile.com>2020-04-20 09:52:00 +0800
committerdyh <dengyuanhong@chinamobile.com>2020-04-20 09:52:19 +0800
commit9d63f079341419d875ac5e697cefde920d26c802 (patch)
treec72b0b3fafea91b3d68387d5850acf803a877bde
parent064488f7193669852e626c04c574984575ebe7ff (diff)
fix bug: Failed to open admin url
Issue-ID: MODELING-355 Change-Id: I93057d2ef94beed1dfa132e4afc78511184e8c12 Signed-off-by: dyh <dengyuanhong@chinamobile.com>
-rw-r--r--catalog/middleware.py10
-rw-r--r--catalog/settings.py3
2 files changed, 11 insertions, 2 deletions
diff --git a/catalog/middleware.py b/catalog/middleware.py
index cd6aa8b..02d4740 100644
--- a/catalog/middleware.py
+++ b/catalog/middleware.py
@@ -11,12 +11,16 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
import uuid
+
from onaplogging.mdcContext import MDC
from catalog.pub.config.config import FORWARDED_FOR_FIELDS, SERVICE_NAME
class LogContextMiddleware(object):
+ def __init__(self, get_response):
+ self.get_response = get_response
+
# the last IP behind multiple proxies, if no exist proxies
# get local host ip.
def _getLastIp(self, request):
@@ -58,3 +62,9 @@ class LogContextMiddleware(object):
def process_response(self, request, response):
MDC.clear()
return response
+
+ def __call__(self, request):
+ self.process_request(request)
+ response = self.get_response(request)
+ self.process_response(request, response)
+ return response
diff --git a/catalog/settings.py b/catalog/settings.py
index 0068dac..cbb90d7 100644
--- a/catalog/settings.py
+++ b/catalog/settings.py
@@ -80,13 +80,12 @@ TEMPLATES = [
},
]
-MIDDLEWARE_CLASSES = [
+MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
- 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'catalog.middleware.LogContextMiddleware',