|
List Info
Thread: cache views (decorator not working)
|
|
| cache views (decorator not working) |

|
2007-02-27 13:20:09 |
|
Hi all
I';m really not good at python, and hence not good at django, but I really love both
I have spent a few hours trying to understand why this works: ------------------
login_required def object_list(request, model, page):
try: return list_detail.object_list( request, queryset = model.objects.all().order_by(9;name'), template_name = 'base/%s_list.html' % model.__name__.lower(),
paginate_by = 3, page = page, ) except: return HttpResponseRedirect('/list/people/';)
object_list = cache_page(object_list, 300)
---------------------------------
And this doesnt: -----------------------------
cache(600)
login_required
def object_list(request, model, page):
try:
return list_detail.object_list(
request,
queryset = model.objects.all().order_by(9;name'),
template_name = 'base/%s_list.html' % model.__name__.lower(),
paginate_by = 3,
page = page,
)
except:
return HttpResponseRedirect('/list/people/';)
---------------------------------
If I take the login_required still doesn't work, so is not a problem about conflicts on the decorators.
Can anybody point anything about this problem and how to correct it
At first I though the version of python could be the problem, but if one decorator works, both of them should isn't it ?
The error I get is this: ------------------------------------------ Request Method:
GET Request URL: http://127.0.0.1:8000/list/ Exception Type: AttributeError Exception Value: 9;function' object has no attribute 'method'
Exception Location: /usr/lib/python2.4/site-packages/django/middleware/cache.py in process_request, line 47 -------------------------------------------
That is exactly here: ----------------------------------------
if not request.method in ('GET', 'HEAD') or request.GET: ------------------------------------------
Thanks in advance !
Max -- <?php $signautre = null; echo $signature;
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users googlegroups.com To unsubscribe from this group, send email to django-users-unsubscribe googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---
|
| Re: cache views (decorator not working) |
  Australia |
2007-02-28 04:00:23 |
On Tue, 2007-02-27 at 13:20 -0600, GaRaGeD Style wrote:
> Hi all
>
> I'm really not good at python, and hence not good at
django, but I
> really love both
>
> I have spent a few hours trying to understand why this
works:
> ------------------
> login_required
> def object_list(request, model, page):
> try:
> return list_detail.object_list(
> request,
> queryset =
model.objects.all().order_by('name'),
> template_name = 'base/%s_list.html' %
> model.__name__.lower(),
> paginate_by = 3,
> page = page,
> )
> except:
> return HttpResponseRedirect('/list/people/')
>
> object_list = cache_page(object_list, 300)
> ---------------------------------
>
> And this doesnt:
> -----------------------------
> cache(600)
> login_required
> def object_list(request, model, page):
> try:
> return list_detail.object_list(
> request,
> queryset =
model.objects.all().order_by('name'),
> template_name = 'base/%s_list.html' %
> model.__name__.lower(),
> paginate_by = 3,
> page = page,
> )
> except:
> return HttpResponseRedirect('/list/people/')
> ---------------------------------
Assuming this is a cut-and-paste of your actual code, you
have mispelt
the decorator name, haven't you? It should be
cache_page(600)
(the same name as in your first example).
Regards,
Malcolm
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-users googlegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribe googlegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: cache views (decorator not working) |
  United States |
2007-02-28 08:47:19 |
I read yor reply on the other thread Malcolm, I think the
problem is
clear, decorator is not actually passing the request, as I
suspected,
your explanation is quite clear
hopefully the decorator will be corrected to reflect the
fact that it
doesn't actually works as expected.
Thanks again !
Max
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-users googlegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribe googlegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: cache views (decorator not working) |
  United States |
2007-02-28 08:40:12 |
On Feb 28, 4:00 am, Malcolm Tredinnick <malc... pointy-stick.com>
wrote:
> On Tue, 2007-02-27 at 13:20 -0600, GaRaGeD Style
wrote:
> > Hi all
>
> > I'm really not good at python, and hence not good
at django, but I
> > really love both
>
> > I have spent a few hours trying to understand why
this works:
> > ------------------
> > login_required
> > def object_list(request, model, page):
> > try:
> > return list_detail.object_list(
> > request,
> > queryset =
model.objects.all().order_by('name'),
> > template_name =
'base/%s_list.html' %
> > model.__name__.lower(),
> > paginate_by = 3,
> > page = page,
> > )
> > except:
> > return
HttpResponseRedirect('/list/people/')
>
> > object_list =cache_page(object_list, 300)
> > ---------------------------------
>
> > And this doesnt:
> > -----------------------------
> > cache(600)
> > login_required
> > def object_list(request, model, page):
> > try:
> > return list_detail.object_list(
> > request,
> > queryset =
model.objects.all().order_by('name'),
> > template_name =
'base/%s_list.html' %
> > model.__name__.lower(),
> > paginate_by = 3,
> > page = page,
> > )
> > except:
> > return
HttpResponseRedirect('/list/people/')
> > ---------------------------------
>
> Assuming this is a cut-and-paste of your actual code,
you have mispelt
> thedecoratorname, haven't you? It should be
>
> cache_page(600)
>
Its a type, I didn't cut-pasted, I use cache_page(600) format, and
the error I get is this:
Exception Value:
'function' object has no attribute 'method'
That is for
/usr/lib/python2.4/site-packages/django/middleware/cache.py
in
process_request
if not request.method in ('GET', 'HEAD') or
request.GET:
And I have no Idea on what is going on there, seems like the
"request"
object is not passing correctly, but I don't know enough
python to say
why.
Thanks for the help !
Max
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-users googlegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribe googlegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
[1-4]
|
|