File: decorators.py

package info (click to toggle)
django-allauth 65.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,672 kB
  • sloc: python: 34,411; javascript: 3,070; xml: 849; makefile: 235; sh: 8
file content (17 lines) | stat: -rw-r--r-- 435 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from functools import wraps

from allauth.core import ratelimit


def rate_limit(*, action, **rl_kwargs):
    def decorator(function):
        @wraps(function)
        def wrap(request, *args, **kwargs):
            resp = ratelimit.consume_or_429(request, action=action, **rl_kwargs)
            if not resp:
                resp = function(request, *args, **kwargs)
            return resp

        return wrap

    return decorator