Opened 13 years ago
Closed 13 years ago
#17643 closed Cleanup/optimization (fixed)
Misleading deprecation warnings raised by the cache_page decorator
Reported by: | Zbigniew Siciarz | Owned by: | Zbigniew Siciarz |
---|---|---|---|
Component: | Core (Other) | Version: | 1.4-alpha-1 |
Severity: | Normal | Keywords: | deprecation |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
The cache_page
decorator should be called in The One True Way, which is:
@cache_page(120) def my_view(request): # ...
Any old-style calls raise now a PendingDeprecationWarning
. However, the warning that is printed to the stdout is misleading with regard to line numbers. All the warnings point to the
warnings.warn
call. It would be more useful to point to the actual
@cache_page
calls.
For the record, this is the current behaviour:
C:\Users\USER\v\django14\django\django\views\decorators\cache.py:47: PendingDeprecationWarning: The cache_page decorator must be called like: cache_page(timeout, [cache=cache name], [key_prefix=key prefix]). All other ways are deprecated. PendingDeprecationWarning) C:\Users\USER\v\django14\django\django\views\decorators\cache.py:47: PendingDeprecationWarning: The cache_page decorator must be called like: cache_page(timeout, [cache=cache name], [key_prefix=key prefix]). All other ways are deprecated. PendingDeprecationWarning) C:\Users\USER\v\django14\django\django\views\decorators\cache.py:47: PendingDeprecationWarning: The cache_page decorator must be called like: cache_page(timeout, [cache=cache name], [key_prefix=key prefix]). All other ways are deprecated. PendingDeprecationWarning) C:\Users\USER\v\django14\django\django\views\decorators\cache.py:47: PendingDeprecationWarning: The cache_page decorator must be called like: cache_page(timeout, [cache=cache name], [key_prefix=key prefix]). All other ways are deprecated. PendingDeprecationWarning)
Attachments (1)
Change History (5)
by , 13 years ago
Attachment: | patch_17643.diff added |
---|
comment:1 by , 13 years ago
Has patch: | set |
---|
comment:2 by , 13 years ago
With the patch applied:
C:\Users\USER\v\django14\django\tests\regressiontests\decorators\tests.py:133: PendingDeprecationWarning: The cache_page decorator must be called like: cache_page(timeout, [cache=cache name], [key_prefix=key prefix]).All other ways are deprecated. my_view_cached = cache_page(my_view, 123) C:\Users\USER\v\django14\django\tests\regressiontests\decorators\tests.py:135: PendingDeprecationWarning: The cache_page decorator must be called like: cache_page(timeout, [cache=cache name], [key_prefix=key prefix]). All other ways are deprecated. my_view_cached2 = cache_page(my_view, 123, key_prefix="test") C:\Users\USER\v\django14\django\tests\regressiontests\decorators\tests.py:137: PendingDeprecationWarning: The cache_page decorator must be called like: cache_page(timeout, [cache=cache name], [key_prefix=key prefix]). All other ways are deprecated. my_view_cached3 = cache_page(my_view) C:\Users\USER\v\django14\django\tests\regressiontests\decorators\tests.py:139: PendingDeprecationWarning: The cache_page decorator must be called like: cache_page(timeout, [cache=cache name], [key_prefix=key prefix]). All other ways are deprecated. my_view_cached4 = cache_page()(my_view)
comment:3 by , 13 years ago
Triage Stage: | Unreviewed → Ready for checkin |
---|
Note:
See TracTickets
for help on using tickets.
Setting correct stacklevel on the warnings.warn call.