Opened 18 years ago

Closed 18 years ago

#4149 closed (invalid)

cache_page decorator documented incorrectly

Reported by: Chris Beaven Owned by: Jacob
Component: Documentation Version: dev
Severity: 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

While investigating #2564, I found that the problem was actually incorrect use of the cache_page decorator, but the documentation recommends this incorrect format.

The current documentation says

It’s easy to use:

from django.views.decorators.cache import cache_page

def slashdot_this(request):
    ...

slashdot_this = cache_page(slashdot_this, 60 * 15)

Or, using Python 2.4’s decorator syntax:

@cache_page(60 * 15)
def slashdot_this(request):
    ...

The Python 2.4 syntax can not be used in this case.

@cache_page(60 * 15) is actually equivalent slashdot_this = cache_page(60 * 15)(slashdot_this) which is obviously incorrect (the cache_page decorator expects the both the function and any arguments to be passed directly to it)

The decorator (which is actually from django.utils.decorators.decorator_from_middleware) is the problem here and perhaps it's format should change - but for now, let's just fix the documentation.

Change History (1)

comment:1 by Malcolm Tredinnick, 18 years ago

Resolution: invalid
Status: newclosed

This is a problem with the decorator, not the documentation.

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