Author: adrian
Date: 2006-08-17 22:31:13 -0500 (Thu, 17 Aug 2006)
New Revision: 3603

Modified:
   django/trunk/django/middleware/cache.py
Log:
Fixed #2541 -- Added helpful error message for CacheMiddleware in the case of 
CACHE_ANONYMOUS_ONLY=True and uninstalled/unordered AuthenticationMiddleware. 
Thanks, [EMAIL PROTECTED]

Modified: django/trunk/django/middleware/cache.py
===================================================================
--- django/trunk/django/middleware/cache.py     2006-08-18 03:12:36 UTC (rev 
3602)
+++ django/trunk/django/middleware/cache.py     2006-08-18 03:31:13 UTC (rev 
3603)
@@ -41,6 +41,9 @@
 
     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.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates
-~----------~----~----~----~------~----~------~--~---

Reply via email to