From 9d63f079341419d875ac5e697cefde920d26c802 Mon Sep 17 00:00:00 2001 From: dyh Date: Mon, 20 Apr 2020 09:52:00 +0800 Subject: [PATCH] fix bug: Failed to open admin url Issue-ID: MODELING-355 Change-Id: I93057d2ef94beed1dfa132e4afc78511184e8c12 Signed-off-by: dyh --- catalog/middleware.py | 10 ++++++++++ catalog/settings.py | 3 +-- 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', -- 2.16.6