Noob question here: why would it need limit=5 if the funcion has default
values?


Best regards,
Andre Terra

On Mon, Nov 29, 2010 at 20:17, Daniel Roseman <dan...@roseman.org.uk> wrote:

> On Nov 29, 8:28 pm, James Matthews <nytrok...@gmail.com> wrote:
> > Hi,
> >
> > When I use this rate limiterhttp://
> www.levigross.com/post/1721427025/django-rate-limitingand preform an
> > ajax request I get this error
> >
> > django/middleware/common.py", line 84, in process_response
> >     if response.status_code == 404:
> > AttributeError: 'function' object has no attribute 'status_code'
> >
> > [CODE]
> > @ratelimit
> > @never_cache
> > def ajaxrequester(request):
> >     if request.is_ajax():
> >         stuff = submitform(request.POST)
> >         return HttpResponse("{'ok':200}",content_type="text/xml")
> >     else:
> >         return HttpResponseForbidden("You don't belong here")
> > [/CODE]
> >
> > Any thoughts?
>
> It looks like that is a callable decorator - it is intended to be
> called immediately, with arguments:
>
> @ratelimit(limit=5)
>   ...etc...
>
> You can tell it's meant to be used like this because of the extra
> level of nested functions: normal decorators just return a function
> (which calls the decorated function), but callable decorators return a
> function (the actual decorator) which itself returns a function.
>
> (Actually I'm not sure that 'callable decorator' is the right term
> here, but I can't think of a better one. Is there a canonical name for
> this sort of thing?)
> --
> DR.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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

Reply via email to