Mercurial > public > sg101
diff gpp/antispam/rate_limit.py @ 565:6a265b5768ca
For bitbucket issue #5, rework the duplicate email checking in the registration
form logic. Added tests for registration.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 04 Mar 2012 13:20:40 -0600 |
parents | 6f5fff924877 |
children | a18516692273 |
line wrap: on
line diff
--- a/gpp/antispam/rate_limit.py Mon Feb 13 19:34:29 2012 -0600 +++ b/gpp/antispam/rate_limit.py Sun Mar 04 13:20:40 2012 -0600 @@ -6,7 +6,6 @@ import logging import redis -from django.conf import settings from core.services import get_redis_connection @@ -71,6 +70,22 @@ logger.info("Rate limiter blocked IP %s; %d / %s", ip, count, interval) +def unblock_ip(ip): + """ + This function removes the block for the given IP address. + + """ + key = _make_key(ip) + conn = _get_connection() + try: + conn.delete(key) + except redis.RedisError, e: + logger.error("rate limit (unblock_ip): %s" % e) + raise RateLimiterUnavailable + + logger.info("Rate limiter unblocked IP %s", ip) + + class RateLimiter(object): """ This class encapsulates the rate limiting logic for a given IP address.