(key, rate)
return outer
Make a blocking rate limiter that does not raise an exception
Make a blocking rate limiter that does not raise an exception
Make a blocking rate limiter that does not raise an exception
def limited(key, rate):
    """
    Make a blocking rate limiter that does not raise an exception
    """
    def outer(func):

        @ratelimit(key=key, rate=rate)
        def inner(request, **kwargs):

            was_limited = getattr(request, 'limited', False)
            if was_limited:
                msg = "Too many requests from same IP address. Temporary ban."
                messages.warning(request, msg)
                raise Http404(msg)

            return func(request, **kwargs)

        return inner

    return outer
def limited ( key , rate ) : def outer ( func ) : @ ratelimit ( key = key , rate = rate ) def inner ( request , * * kwargs ) : was_limited = getattr ( request , 'limited' , False ) if was_limited : msg = "Too many requests from same IP address. Temporary ban." messages . warning ( request , msg ) raise Http404 ( msg ) return func ( request , * * kwargs ) return inner return outer