Opened 19 years ago
Closed 19 years ago
#2396 closed defect (fixed)
Cache change fails under fcgi
| Reported by: | Kevin | Owned by: | Jacob | 
|---|---|---|---|
| Component: | Core (Cache system) | Version: | |
| Severity: | normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no | 
| Needs tests: | no | Patch needs improvement: | no | 
| Easy pickings: | no | UI/UX: | no | 
Description
Running under lighttpd and fcgi, new setting CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True leads to..
2006-07-22 09:24:04: (mod_fastcgi.c.2536) FastCGI-stderr: Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/flup/server/fcgi_base.py", line 556, in run
protocolStatus, appStatus = self.server.handler(self)
File "/usr/lib/python2.4/site-packages/flup/server/fcgi_base.py", line 1086, in handler
result = self.application(environ, start_response)
File "/usr/lib/python2.4/site-packages/django/core/handlers/wsgi.py", line 148, in call
response = self.get_response(request.path, request)
File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py", line 59, in get_response
response = middleware_method(request)
File "/usr/lib/python2.4/site-packages/django/middleware/cache.py", line 49, in process_request
if self.cache_anonymous_only and request.user.is_authenticated():
AttributeError: 'WSGIRequest' object has no attribute 'user'
 
2006-07-22 09:24:04: (mod_fastcgi.c.2536) FastCGI-stderr:  
I had the same problem.
the 'fix' is to move the cachemiddleware setting to AFTER the user setting
ala
MIDDLEWARE_CLASSES = ( ... "django.contrib.auth.middleware.AuthenticationMiddleware", 'django.middleware.cache.CacheMiddleware', ... )It works great too!