Projet

Général

Profil

0001-misc-update-to-new-style-middlewares-with-compat-lay.patch

Frédéric Péters, 01 avril 2020 17:39

Télécharger (3,25 ko)

Voir les différences:

Subject: [PATCH 1/4] misc: update to new style middlewares (with compat layer)
 (#41236)

 debian/debian_config.py | 7 ++-----
 wcs/compat.py           | 3 ++-
 wcs/middleware.py       | 5 +++--
 wcs/settings.py         | 2 +-
 4 files changed, 8 insertions(+), 9 deletions(-)
debian/debian_config.py
15 15
        'hobo.context_processors.theme_base',
16 16
        ] + TEMPLATES[0]['OPTIONS']['context_processors']
17 17

  
18
if not 'MIDDLEWARE_CLASSES' in globals():
19
    MIDDLEWARE_CLASSES = global_settings.MIDDLEWARE_CLASSES
20

  
21
MIDDLEWARE_CLASSES = (
18
MIDDLEWARE = (
22 19
    'hobo.middleware.utils.StoreRequestMiddleware',
23 20
    'hobo.middleware.xforwardedfor.XForwardedForMiddleware',
24 21
    'hobo.middleware.VersionMiddleware', # /__version__
25 22
    'hobo.middleware.cors.CORSMiddleware',
26
) + MIDDLEWARE_CLASSES
23
) + MIDDLEWARE
27 24

  
28 25
CACHES = {
29 26
    'default': {
wcs/compat.py
20 20
from contextlib import contextmanager
21 21

  
22 22
from django.utils import six
23
from django.utils.deprecation import MiddlewareMixin
23 24

  
24 25
from quixote import get_publisher, get_request
25 26
from quixote.errors import PublishError
......
249 250
    pub._clear_request()
250 251

  
251 252

  
252
class PublishErrorMiddleware(object):
253
class PublishErrorMiddleware(MiddlewareMixin):
253 254
    def process_exception(self, request, exception):
254 255
        if not isinstance(exception, PublishError):
255 256
            return None
wcs/middleware.py
19 19
import time
20 20

  
21 21
from django.http import HttpResponseBadRequest, HttpResponseRedirect
22
from django.utils.deprecation import MiddlewareMixin
22 23
from django.utils.six.moves.urllib import parse as urllib
23 24

  
24 25
from quixote import get_publisher
......
28 29
from .compat import CompatHTTPRequest, CompatWcsPublisher
29 30

  
30 31

  
31
class PublisherInitialisationMiddleware(object):
32
class PublisherInitialisationMiddleware(MiddlewareMixin):
32 33
    '''Initializes the publisher according to the request server name.'''
33 34
    def process_request(self, request):
34 35
        pub = get_publisher()
......
95 96
        return response
96 97

  
97 98

  
98
class AfterJobsMiddleware(object):
99
class AfterJobsMiddleware(MiddlewareMixin):
99 100
    ASYNC = True
100 101

  
101 102
    def process_response(self, request, response):
wcs/settings.py
112 112
    },
113 113
]
114 114

  
115
MIDDLEWARE_CLASSES = (
115
MIDDLEWARE = (
116 116
    'django.middleware.common.CommonMiddleware',
117 117
    'wcs.middleware.PublisherInitialisationMiddleware',
118 118
    #'django.contrib.sessions.middleware.SessionMiddleware',
119
-