summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2006-08-18 03:31:13 +0000
committerAdrian Holovaty <adrian@holovaty.com>2006-08-18 03:31:13 +0000
commitd592ca487ae4be5b7fdc22e6022bb766eeafab39 (patch)
treee7dd89e27f96a18dbc0b7392f1879fcde5a6ad30
parent8f065bba6b262fe7b1bfde15e70bcbc7e4602a48 (diff)
downloaddjango-d592ca487ae4be5b7fdc22e6022bb766eeafab39.tar.gz
Fixed #2541 -- Added helpful error message for CacheMiddleware in the case of CACHE_ANONYMOUS_ONLY=True and uninstalled/unordered AuthenticationMiddleware. Thanks, dummy@habmalnefrage.de
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3603 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/middleware/cache.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/django/middleware/cache.py b/django/middleware/cache.py
index 08e77d1375..58800b24da 100644
--- a/django/middleware/cache.py
+++ b/django/middleware/cache.py
@@ -41,6 +41,9 @@ class CacheMiddleware(object):
def process_request(self, request):
"Checks whether the page is already cached and returns the cached version if available."
+ if self.cache_anonymous_only:
+ assert hasattr(request, 'user'), "The Django cache middleware with CACHE_MIDDLEWARE_ANONYMOUS_ONLY=True requires authentication middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.auth.middleware.AuthenticationMiddleware' before the CacheMiddleware."
+
if not request.method in ('GET', 'HEAD') or request.GET:
request._cache_update_cache = False
return None # Don't bother checking the cache.