misc: update to new style middlewares (with compat layer) (#41236)
This commit is contained in:
parent
d52fbc23b3
commit
e7463c49ad
|
@ -15,15 +15,12 @@ TEMPLATES[0]['OPTIONS']['context_processors'] = [
|
|||
'hobo.context_processors.theme_base',
|
||||
] + TEMPLATES[0]['OPTIONS']['context_processors']
|
||||
|
||||
if not 'MIDDLEWARE_CLASSES' in globals():
|
||||
MIDDLEWARE_CLASSES = global_settings.MIDDLEWARE_CLASSES
|
||||
|
||||
MIDDLEWARE_CLASSES = (
|
||||
MIDDLEWARE = (
|
||||
'hobo.middleware.utils.StoreRequestMiddleware',
|
||||
'hobo.middleware.xforwardedfor.XForwardedForMiddleware',
|
||||
'hobo.middleware.VersionMiddleware', # /__version__
|
||||
'hobo.middleware.cors.CORSMiddleware',
|
||||
) + MIDDLEWARE_CLASSES
|
||||
) + MIDDLEWARE
|
||||
|
||||
CACHES = {
|
||||
'default': {
|
||||
|
|
|
@ -20,6 +20,7 @@ from threading import Lock
|
|||
from contextlib import contextmanager
|
||||
|
||||
from django.utils import six
|
||||
from django.utils.deprecation import MiddlewareMixin
|
||||
|
||||
from quixote import get_publisher, get_request
|
||||
from quixote.errors import PublishError
|
||||
|
@ -249,7 +250,7 @@ def request(request):
|
|||
pub._clear_request()
|
||||
|
||||
|
||||
class PublishErrorMiddleware(object):
|
||||
class PublishErrorMiddleware(MiddlewareMixin):
|
||||
def process_exception(self, request, exception):
|
||||
if not isinstance(exception, PublishError):
|
||||
return None
|
||||
|
|
|
@ -19,6 +19,7 @@ import threading
|
|||
import time
|
||||
|
||||
from django.http import HttpResponseBadRequest, HttpResponseRedirect
|
||||
from django.utils.deprecation import MiddlewareMixin
|
||||
from django.utils.six.moves.urllib import parse as urllib
|
||||
|
||||
from quixote import get_publisher
|
||||
|
@ -28,7 +29,7 @@ from .qommon.http_response import HTTPResponse
|
|||
from .compat import CompatHTTPRequest, CompatWcsPublisher
|
||||
|
||||
|
||||
class PublisherInitialisationMiddleware(object):
|
||||
class PublisherInitialisationMiddleware(MiddlewareMixin):
|
||||
'''Initializes the publisher according to the request server name.'''
|
||||
def process_request(self, request):
|
||||
pub = get_publisher()
|
||||
|
@ -95,7 +96,7 @@ class PublisherInitialisationMiddleware(object):
|
|||
return response
|
||||
|
||||
|
||||
class AfterJobsMiddleware(object):
|
||||
class AfterJobsMiddleware(MiddlewareMixin):
|
||||
ASYNC = True
|
||||
|
||||
def process_response(self, request, response):
|
||||
|
|
|
@ -112,7 +112,7 @@ TEMPLATES = [
|
|||
},
|
||||
]
|
||||
|
||||
MIDDLEWARE_CLASSES = (
|
||||
MIDDLEWARE = (
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'wcs.middleware.PublisherInitialisationMiddleware',
|
||||
#'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
|
|
Loading…
Reference in New Issue