Skip to content

Commit

Permalink
update for Django 1.11, bump version to 0.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejsika committed Apr 18, 2017
1 parent 54f5979 commit fb8f0e1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
27 changes: 24 additions & 3 deletions cached_auth/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION = (0, 2, 1)
VERSION = (0, 2, 2)

from django.conf import settings
from django.contrib.auth import get_user, SESSION_KEY
Expand Down Expand Up @@ -79,9 +79,30 @@ def get_cached_user(request):
return request._cached_user


class Middleware(object):
class MiddlewareMixin(object):
"""
Ported from Django 1.11: django.utils.deprecation.MiddlewareMixin
"""
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 Middleware(MiddlewareMixin):

def __init__(self, *args, **kwargs):
super(Middleware, self).__init__(*args, **kwargs)

def __init__(self):
post_save.connect(invalidate_cache, sender=get_user_model())
post_delete.connect(invalidate_cache, sender=get_user_model())
if profile_model:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

setup(
name='django-cached_authentication_middleware',
version='0.2.1',
version='0.2.2',
author='Selwin Ong',
author_email='[email protected]',
packages=['cached_auth'],
Expand Down

0 comments on commit fb8f0e1

Please sign in to comment.