Refs #26601 -- Removed obsolete workarounds for MIDDLEWARE_CLASSES setting.

This commit is contained in:
Sergey Fedoseev 2019-10-22 16:01:14 +05:00 committed by Mariusz Felisiak
parent d4e767911f
commit 0315c18fe1
4 changed files with 6 additions and 10 deletions

View File

@ -18,10 +18,8 @@ class XViewMiddleware(MiddlewareMixin):
"""
assert hasattr(request, 'user'), (
"The XView middleware requires authentication middleware to be "
"installed. Edit your MIDDLEWARE%s setting to insert "
"'django.contrib.auth.middleware.AuthenticationMiddleware'." % (
"_CLASSES" if settings.MIDDLEWARE is None else ""
)
"installed. Edit your MIDDLEWARE setting to insert "
"'django.contrib.auth.middleware.AuthenticationMiddleware'."
)
if request.method == 'HEAD' and (request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS or
(request.user.is_active and request.user.is_staff)):

View File

@ -1,4 +1,3 @@
from django.conf import settings
from django.contrib import auth
from django.contrib.auth import load_backend
from django.contrib.auth.backends import RemoteUserBackend
@ -17,10 +16,10 @@ class AuthenticationMiddleware(MiddlewareMixin):
def process_request(self, request):
assert hasattr(request, 'session'), (
"The Django authentication middleware requires session middleware "
"to be installed. Edit your MIDDLEWARE%s setting to insert "
"to be installed. Edit your MIDDLEWARE setting to insert "
"'django.contrib.sessions.middleware.SessionMiddleware' before "
"'django.contrib.auth.middleware.AuthenticationMiddleware'."
) % ("_CLASSES" if settings.MIDDLEWARE is None else "")
)
request.user = SimpleLazyObject(lambda: get_user(request))

View File

@ -1,6 +1,5 @@
import json
from django.conf import settings
from django.contrib.messages.storage.base import BaseStorage
from django.contrib.messages.storage.cookie import (
MessageDecoder, MessageEncoder,
@ -17,7 +16,7 @@ class SessionStorage(BaseStorage):
assert hasattr(request, 'session'), "The session-based temporary "\
"message storage requires session middleware to be installed, "\
"and come before the message middleware in the "\
"MIDDLEWARE%s list." % ("_CLASSES" if settings.MIDDLEWARE is None else "")
"MIDDLEWARE list."
super().__init__(request, *args, **kwargs)
def _get(self, *args, **kwargs):

View File

@ -163,7 +163,7 @@ class CsrfViewMiddleware(MiddlewareMixin):
raise ImproperlyConfigured(
'CSRF_USE_SESSIONS is enabled, but request.session is not '
'set. SessionMiddleware must appear before CsrfViewMiddleware '
'in MIDDLEWARE%s.' % ('_CLASSES' if settings.MIDDLEWARE is None else '')
'in MIDDLEWARE.'
)
else:
try: