Best regards,
Andre Terra
On Mon, Nov 29, 2010 at 20:17, Daniel Roseman <daniel@roseman.org.uk> wrote:
> When I use this rate limiterhttp://www.levigross.com/post/1721427025/django-rate-limitingand preform an
> ajax request I get this errorIt looks like that is a callable decorator - it is intended to be
>
> 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?
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-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.
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.
No comments:
Post a Comment