#12019 closed (fixed)
@cache_page with no args causes IndexError
Reported by: | rokclimb15 | Owned by: | nobody |
---|---|---|---|
Component: | Core (Cache system) | Version: | dev |
Severity: | Keywords: | @cache_page | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | yes | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
When calling @cache_page with no arguments I get the following exception while running mod_wsgi. I'm not sure if that usage is valid. I would assume it would use CACHE_MIDDLEWARE_SECONDS if nothing is provided, but I can't find anything about that in docs or see any evidence of that in the code. If that argument is required, I think a clear exception should be thrown rather than this one when running under mod_wsgi.
Traceback (most recent call last): File "/usr/lib/python2.6/dist-packages/django/core/handlers/base.py", line 92, in get_response response = callback(request, *callback_args, **callback_kwargs) File "/usr/lib/python2.6/dist-packages/django/utils/decorators.py", line 33, in adapt return MethodDecoratorAdaptor(decorator, func) File "/usr/lib/python2.6/dist-packages/django/utils/decorators.py", line 15, in __init__ update_wrapper(self, func) File "/usr/lib/python2.6/functools.py", line 33, in update_wrapper setattr(wrapper, attr, getattr(wrapped, attr)) AttributeError: 'WSGIRequest' object has no attribute '__name__'
Attachments (2)
Change History (10)
comment:1 by , 15 years ago
Description: | modified (diff) |
---|
comment:2 by , 15 years ago
Triage Stage: | Unreviewed → Accepted |
---|
follow-up: 4 comment:3 by , 15 years ago
Has patch: | set |
---|---|
Keywords: | @cache_page added |
Summary: | @cache_page with no args causes AttributeError with wsgi → @cache_page with no args causes IndexError |
Version: | 1.1 → SVN |
This behavior with mod_wsgi actually translates to an IndexError in the cache decorator code. The docs at http://docs.djangoproject.com/en/dev/ref/settings/#cache-middleware-seconds state that this setting will be used as a default for the cache middleware and decorators, which is not currently true. The attached patch adds this functionality to match the documentation, which is also a sensible behavior in my opinion. The patch isn't particularly pretty, but neither is this decorator's code since it is littered with backwards compat functionality.
comment:4 by , 14 years ago
Replying to rokclimb15:
This behavior with mod_wsgi actually translates to an IndexError in the cache decorator code. The docs at http://docs.djangoproject.com/en/dev/ref/settings/#cache-middleware-seconds state that this setting will be used as a default for the cache middleware and decorators, which is not currently true. The attached patch adds this functionality to match the documentation, which is also a sensible behavior in my opinion. The patch isn't particularly pretty, but neither is this decorator's code since it is littered with backwards compat functionality.
This patch seems to work fine for me as well. Any chance of this getting fixed?
by , 14 years ago
Attachment: | cache_page_default_timeout.diff added |
---|
Slightly different approach at patch, includes test
comment:6 by , 14 years ago
Added a slightly different approach at the patch, which allows the middleware to deal with the default cache timeout value. Hopefully a little more DRY. Also added a test.
comment:7 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Please use preview.