Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.6 / 3....
  • Linux Kernel 3.0.82 LTS...
  • KDE Software Compilatio...
  • PulseAudio 4.0
  • Wireshark 1.10.0
  • NetworkManager 0.9.8.2
  • LibreOffice 3.6.6 / 4.0...
  • SystemRescueCd 3.7.0
  • Linux Kernel 3.10 RC6
  • Ubuntu Tweak 0.8.5
  • Home > Linux > Internet > HTTP (WWW)

    django-ratelimit 0.1

    Download button

    No screenshots available
    Downloads: 164  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    James Socol | More programs
    BSD License / FREE
    May 23rd, 2011, 19:59 GMT
    ROOT / Internet / HTTP (WWW)

     Read user reviews (0)  Refer to a friend  Subscribe

    django-ratelimit description

    Cache-based rate-limiting for Django

    django-ratelimit is a Django app that provides a decorator to rate-limit views. Limiting can be based on IP address or a field in the request--either a GET or POST variable.

    If the rate limit is exceded, either a 403 Forbidden can be sent, or the request can be annotated with a limited attribute, allowing you to take another action like adding a captcha to a form.

    Using Django Ratelimit

    from ratelimit.decorators import ratelimit is the biggest thing you need to do. The @ratelimit decorator provides several optional arguments with sensible defaults (in italics).
    ip: Whether to rate-limit based on the IP. True
    block: Whether to block the request instead of annotating. False
    method: Which HTTP method(s) to rate-limit. May be a string or a list. all
    field: Which HTTP field(s) to use to rate-limit. May be a string or a list. none
    rate: The number of requests per unit time allowed. 5/m

    Examples:

    @ratelimit()
    def myview(request):
     # Will be true if the same IP makes more than 5 requests/minute.
     was_limited = getattr(request, 'limited', False)
     return HttpResponse()

    @ratelimit(block=True)
    def myview(request):
     # If the same IP makes >5 reqs/min, will return HttpResponseForbidden
     return HttpResponse()

    @ratelimit(field='username')
    def login(request):
     # If the same username OR IP is used >5 times/min, this will be True.
     # The `username` value will come from GET or POST, determined by the
     # request method.
     was_limited = getattr(request, 'limited', False)
     return HttpResponse()

    @ratelimit(method='POST')
    def login(request):
     # Only apply rate-limiting to POSTs.
     return HttpResponseRedirect()

    @ratelimit(field=['username', 'other_field'])
    def login(request):
     # Use multiple field values.
     return HttpResponse()

    @ratelimit(rate='4/h')
    def slow(request):
     # Allow 4 reqs/hour.
     return HttpResponse()



    Product's homepage

    Requirements:

    · Python
    · Django

      


    TAGS:

    Django decorator | rate-limit views | cache rate-limiting | Django | rate-limit | decorator

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM