Commit 437b249d by Calen Pennington

Use django_crum to access the current request in request_cache

parent 93970f34
......@@ -312,6 +312,7 @@ simplefilter('ignore')
################################# Middleware ###################################
MIDDLEWARE_CLASSES = (
'crum.CurrentRequestUserMiddleware',
'request_cache.middleware.RequestCache',
'header_control.middleware.HeaderControlMiddleware',
'django.middleware.cache.UpdateCacheMiddleware',
......@@ -332,7 +333,6 @@ MIDDLEWARE_CLASSES = (
'student.middleware.UserStandingMiddleware',
'contentserver.middleware.StaticContentServer',
'crum.CurrentRequestUserMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'track.middleware.TrackMiddleware',
......
"""
An implementation of a RequestCache. This cache is reset at the beginning
and end of every request.
"""
import crum
import threading
......@@ -8,7 +14,6 @@ class _RequestCache(threading.local):
def __init__(self):
super(_RequestCache, self).__init__()
self.data = {}
self.request = None
REQUEST_CACHE = _RequestCache()
......@@ -30,7 +35,7 @@ class RequestCache(object):
"""
This method is deprecated. Please use :func:`request_cache.get_request`.
"""
return REQUEST_CACHE.request
return crum.get_current_request()
@classmethod
def clear_request_cache(cls):
......@@ -38,11 +43,9 @@ class RequestCache(object):
Empty the request cache.
"""
REQUEST_CACHE.data = {}
REQUEST_CACHE.request = None
def process_request(self, request):
self.clear_request_cache()
REQUEST_CACHE.request = request
return None
def process_response(self, request, response):
......
......@@ -1087,7 +1087,10 @@ simplefilter('ignore')
################################# Middleware ###################################
MIDDLEWARE_CLASSES = (
'crum.CurrentRequestUserMiddleware',
'request_cache.middleware.RequestCache',
'mobile_api.middleware.AppVersionUpgrade',
'header_control.middleware.HeaderControlMiddleware',
'microsite_configuration.middleware.MicrositeMiddleware',
......@@ -1111,7 +1114,6 @@ MIDDLEWARE_CLASSES = (
'student.middleware.UserStandingMiddleware',
'contentserver.middleware.StaticContentServer',
'crum.CurrentRequestUserMiddleware',
# Adds user tags to tracking events
# Must go before TrackMiddleware, to get the context set up
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment