0001-misc-make-middlewares-compatible-with-MIDDLEWARE-set.patch
hobo/middleware/cors.py | ||
---|---|---|
2 | 2 | |
3 | 3 |
from django.conf import settings |
4 | 4 |
from django.http import HttpResponse |
5 |
from django.utils.deprecation import MiddlewareMixin |
|
5 | 6 | |
6 |
class CORSMiddleware(object):
|
|
7 |
class CORSMiddleware(MiddlewareMixin):
|
|
7 | 8 |
def process_request(self, request): |
8 | 9 |
""" |
9 | 10 |
If CORS preflight header, then create an |
hobo/middleware/stats.py | ||
---|---|---|
20 | 20 |
import django |
21 | 21 |
from django.db import connection |
22 | 22 |
from django.http import HttpResponse |
23 |
from django.utils.deprecation import MiddlewareMixin |
|
23 | 24 | |
24 | 25 |
import prometheus_client |
25 | 26 | |
26 |
if django.VERSION >= (1, 10, 0): |
|
27 |
from django.utils.deprecation import MiddlewareMixin |
|
28 |
else: |
|
29 |
MiddlewareMixin = object |
|
30 | ||
31 | 27 | |
32 | 28 |
requests_total_by_host_view_status_method = prometheus_client.Counter( |
33 | 29 |
'django_http_requests_total_by_host_view_status_method', |
hobo/middleware/utils.py | ||
---|---|---|
1 | 1 |
import threading |
2 |
from django.utils.deprecation import MiddlewareMixin |
|
2 | 3 | |
3 |
class StoreRequestMiddleware(object):
|
|
4 |
class StoreRequestMiddleware(MiddlewareMixin):
|
|
4 | 5 |
collection = {} |
5 | 6 | |
6 | 7 |
def process_request(self, request): |
hobo/middleware/version.py | ||
---|---|---|
1 | 1 |
import json |
2 | 2 | |
3 | 3 |
from django.http import HttpResponse |
4 |
from django.utils.deprecation import MiddlewareMixin |
|
4 | 5 | |
5 | 6 |
from hobo.scrutiny.wsgi import middleware |
6 | 7 | |
7 |
class VersionMiddleware(object):
|
|
8 |
class VersionMiddleware(MiddlewareMixin):
|
|
8 | 9 |
def process_request(self, request): |
9 | 10 |
if request.method == 'GET' and (request.path == '/__version__' or |
10 | 11 |
request.path == '/__version__/'): |
hobo/middleware/xforwardedfor.py | ||
---|---|---|
1 | 1 |
from django.conf import settings |
2 |
from django.utils.deprecation import MiddlewareMixin |
|
2 | 3 | |
3 | 4 | |
4 |
class XForwardedForMiddleware(object):
|
|
5 |
class XForwardedForMiddleware(MiddlewareMixin):
|
|
5 | 6 |
'''Copy the first address from X-Forwarded-For header to the REMOTE_ADDR meta. |
6 | 7 | |
7 | 8 |
This middleware should only be used if you are sure the header cannot be |
hobo/multitenant/middleware.py | ||
---|---|---|
2 | 2 |
import glob |
3 | 3 |
import hashlib |
4 | 4 | |
5 |
from django.utils.deprecation import MiddlewareMixin |
|
5 | 6 |
from django.utils.encoding import smart_bytes |
6 | 7 |
from django.conf import settings |
7 | 8 |
from django.db import connection |
... | ... | |
14 | 15 |
class TenantNotFound(RuntimeError): |
15 | 16 |
pass |
16 | 17 | |
17 |
class TenantMiddleware(object):
|
|
18 |
class TenantMiddleware(MiddlewareMixin):
|
|
18 | 19 |
""" |
19 | 20 |
This middleware should be placed at the very top of the middleware stack. |
20 | 21 |
Selects the proper database schema using the request host. Can fail in |
hobo/scrutiny/wsgi/middleware.py | ||
---|---|---|
1 | 1 |
from django.utils.six.moves.urllib.parse import quote |
2 |
from django.utils.deprecation import MiddlewareMixin |
|
2 | 3 | |
3 | 4 |
import json |
4 | 5 |
import pkg_resources |
... | ... | |
7 | 8 |
except ImportError: |
8 | 9 |
apt_cache = None |
9 | 10 | |
10 |
class VersionMiddleware(object):
|
|
11 |
class VersionMiddleware(MiddlewareMixin):
|
|
11 | 12 |
ENTROUVERT_PACKAGES = [ |
12 | 13 |
'wcs', |
13 | 14 |
'wcs-au-quotidien', |
14 |
- |