From 490489c17017b39634ecbb670d1e47b80d843562 Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Wed, 1 Apr 2020 20:43:44 +0200 Subject: [PATCH] Update middleware and config for Django 2.2 --- django/archives/mailarchives/redirecthandler.py | 6 ++++++ django/archives/settings.py | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/django/archives/mailarchives/redirecthandler.py b/django/archives/mailarchives/redirecthandler.py index fc6a575..9506508 100644 --- a/django/archives/mailarchives/redirecthandler.py +++ b/django/archives/mailarchives/redirecthandler.py @@ -7,6 +7,12 @@ class ERedirect(Exception): class RedirectMiddleware(object): + def __init__(self, get_response): + self.get_response = get_response + + def __call__(self, request): + return self.get_response(request) + def process_exception(self, request, exception): if isinstance(exception, ERedirect): return shortcuts.redirect(exception.url) diff --git a/django/archives/settings.py b/django/archives/settings.py index c6413fe..906d91b 100644 --- a/django/archives/settings.py +++ b/django/archives/settings.py @@ -77,7 +77,7 @@ STATICFILES_DIRS = ( # Make this unique, and don't share it with anybody. SECRET_KEY = '7j9q&&!g26rkh!=g%1zb@20b^k^gmzy4=!mhzu2wesxb9b%16m' -MIDDLEWARE_CLASSES = [ +MIDDLEWARE = [ 'django.middleware.common.CommonMiddleware', ] @@ -150,12 +150,12 @@ except ImportError: # If this is a non-public site, enable middleware for handling logins etc if ALLOW_RESEND or not PUBLIC_ARCHIVES: - MIDDLEWARE_CLASSES = [ + MIDDLEWARE = [ 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', - ] + MIDDLEWARE_CLASSES - MIDDLEWARE_CLASSES.append('archives.mailarchives.redirecthandler.RedirectMiddleware') + ] + MIDDLEWARE + MIDDLEWARE.append('archives.mailarchives.redirecthandler.RedirectMiddleware') INSTALLED_APPS = [ 'django.contrib.sessions', -- 2.39.5