On Wednesday 23 September 2009 23:40:25 James Bennett wrote:

> So, I've worked out what the problem is.
> 
> Previously either of these worked:
> 
> cache_page(timeout, view)
> cache_page(view, timeout)
> 
> Now, cache_page assumes that the first positional argument will be
>  the timeout. So what we're seeing when running some of our code on
>  trunk is cache_page treating the timeout value (an integer) as the
>  view to be cached, and failing when trying to find things like
>  __module__ attached to it.
> 
> I don't know for certain how many people may be using this idiom,
> since it was never documented (AFAICT cache_page always documented
> itself as putting the timeout first and the view function second),
>  so I'm not really sure what (if anything) we should do about it.
> 
> There may also be deeper issues with the fact that it's not
>  possible to call cache_page with explicit keyword args, since it
>  accepts **kwargs but doesn't do anything with it, always assuming
>  that the timeout and view can be pulled from positional args.

I deliberately wrote it the way it is documented, and only that way. 
So it accepts these forms:

cache_page(timeout, view)
cache_page(timeout)(view)

It shouldn't accept **kwargs though, that's a mistake, because it does 
nothing with them, and it would be better to fail loudly in that case.

I've fixed that, and also added some asserts to get a better error 
message for now unsupported ways of calling it. Do you think this is 
enough?

Luke

-- 
"Pretension: The downside of being better than everyone else is 
that people tend to assume you're pretentious." (despair.com)

Luke Plant || http://lukeplant.me.uk/

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to