Skip to content

Commit

Permalink
Fix jsocol#3 - Cache backend cleans POSTed data before storing.
Browse files Browse the repository at this point in the history
Memcache doesn't like some characters.
  • Loading branch information
Paul Craciunoiu committed Oct 1, 2011
1 parent dd05255 commit 5436206
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ratelimit/backends/cachebe.py
@@ -1,3 +1,5 @@
import hashlib

from django.core.cache import cache

from ratelimit.backends import BaseBackend
Expand All @@ -16,6 +18,9 @@ def _keys(self, request, ip=True, field=None):
field = [field]
for f in field:
val = getattr(request, request.method).get(f)
# Convert value to hexdigest as cache backend doesn't allow
# certain characters.
val = hashlib.sha1(val).hexdigest()
keys.append(u'field:%s:%s' % (f, val))
return [CACHE_PREFIX + k for k in keys]

Expand Down

0 comments on commit 5436206

Please sign in to comment.