Skip to content

Commit

Permalink
Added MiddlewareMixin for compatibility reasons
Browse files Browse the repository at this point in the history
  • Loading branch information
tangochin committed Jan 31, 2018
1 parent 0bc835c commit 339aa5b
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion djangoseo/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,28 @@
logger = getLogger(__name__)


class RedirectsMiddleware(object):
# TODO: replace after upgrade to Django 1.10
class MiddlewareMixin(object):
"""
This mixin a full copy of Django 1.10 django.utils.deprecation.MiddlewareMixin.
Needed for compatibility reasons.
"""
def __init__(self, get_response=None):
self.get_response = get_response
super(MiddlewareMixin, self).__init__()

def __call__(self, request):
response = None
if hasattr(self, 'process_request'):
response = self.process_request(request)
if not response:
response = self.get_response(request)
if hasattr(self, 'process_response'):
response = self.process_response(request, response)
return response


class RedirectsMiddleware(MiddlewareMixin):

def process_exception(self, request, exception):
if not getattr(settings, 'SEO_USE_REDIRECTS', False):
Expand Down

0 comments on commit 339aa5b

Please sign in to comment.