Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lambda increment functions choke on ratelimited views #10

Closed
jvc26 opened this issue Mar 19, 2014 · 2 comments
Closed

lambda increment functions choke on ratelimited views #10

jvc26 opened this issue Mar 19, 2014 · 2 comments

Comments

@jvc26
Copy link
Contributor

jvc26 commented Mar 19, 2014

Currently:

@ratelimit(increment=lambda req, resp: resp.count)
def login(request):
    resp = HttpResponseRedirect()
    if login_is_correct:
        # Do not count correct logins against the limit.
        resp.count = False
    else:
        resp.count = True
    return resp

Fails if the ratelimit kicks in:

AttributeError: 'HttpResponseTooManyRequests' object has no attribute 'count'

Ratelimit decorator should not increment, or should not call increment function if the response is a HttpResponseTooManyRequests object

@gmcquillan
Copy link
Owner

Nice catch. Thanks for the PR, too!

gmcquillan added a commit that referenced this issue Jul 1, 2015
@skorokithakis
Copy link
Contributor

Should this be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants