But, the way that that
django.utils.decorators.decorator_from_middleware is implemented, it
doesn't seem to able to handle a decorator that takes arguments
Eg,
my code works if I write it as:
@cache_page
def slashdot_this(request):
.....
but not with the timeout argument.
It seems to be a result of having to add an extra layer of indirection
to decorators to support arguments, from the python docs:
Decorator functions can take arguments. If arguments are supplied, your
decorator function is called with only those arguments and must return
a new decorator function; this function must take a single function and
return a function, as previously described. In other words, @A @B
@C(args) becomes:
def f(): ...
_deco = C(args)
f = A(B(_deco(f)))
http://docs.python.org/whatsnew/node6.html
Can anyone else confirm this?
My code does work as follow:
slashdot_this = cache_page(slashdot_this, 60 * 15)