comparison gpp/accounts/management/commands/rate_limit_clear.py @ 508:6f5fff924877

Created a centralized spot to get a Redis connection so that settings can be managed in one place.
author Brian Neal <bgneal@gmail.com>
date Sun, 04 Dec 2011 19:53:27 +0000
parents 09a9402e4a71
children
comparison
equal deleted inserted replaced
507:8631d32e6b16 508:6f5fff924877
6 from optparse import make_option 6 from optparse import make_option
7 import re 7 import re
8 8
9 from django.core.management.base import BaseCommand 9 from django.core.management.base import BaseCommand
10 import redis 10 import redis
11
12 from core.services import get_redis_connection
13
11 14
12 IP_RE = re.compile(r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$') 15 IP_RE = re.compile(r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$')
13 16
14 17
15 class Command(BaseCommand): 18 class Command(BaseCommand):
19 help="Purge all IP addresses"), 22 help="Purge all IP addresses"),
20 ] 23 ]
21 24
22 def handle(self, *args, **kwargs): 25 def handle(self, *args, **kwargs):
23 try: 26 try:
24 con = redis.Redis() 27 con = get_redis_connection()
25 28
26 # get all rate-limit keys 29 # get all rate-limit keys
27 keys = con.keys('rate-limit-*') 30 keys = con.keys('rate-limit-*')
28 31
29 # if purging, delete them all... 32 # if purging, delete them all...