Opened 15 years ago

Last modified 13 years ago

#13093 closed

cache_page decorator doesn't work on callable classes — at Initial Version

Reported by: Russell Keith-Magee Owned by: nobody
Component: Core (Cache system) Version: 1.2-beta
Severity: Keywords:
Cc: Brian Neal Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The cache_page() decorator works fine on views, but fails if you use it on a callable class::
class:

class MyView(object):
    def __call__(self, request):
        return HttpResponse()

If you try to wrap this view in urls.py ( cache_page(MyView(), 60) ), you get an error saying "MyView doesn't have attribute name". cache_page uses the name attribute to build a cache key, but classes dont have a name attribute. cache_page should also check for class.name (or some similar key with a per-instance feature) to allow for wrapping callable classes.

This is a problem for 1.2, because feed views have been moved to a class-based structure, so it is no longer possible to cache feed views using cache_page().

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top