Skip to content

Commit

Permalink
Merge pull request #20 from fabiobatalha/tk19
Browse files Browse the repository at this point in the history
Gerando md5 para chaves de cache muito grandes
  • Loading branch information
fabiobatalha committed Nov 13, 2015
2 parents ad5d3f4 + ac71100 commit c28435f
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions analytics/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import weakref
import re
import unicodedata
import hashlib

try:
from ConfigParser import SafeConfigParser
Expand All @@ -19,23 +20,29 @@ def dogpile_controller_key_generator(namespace, fn, *kwargs):

def generate_key(*the_args, **the_kwargs):

key = [
tp = tuple([
str(namespace),
str(fname)
]
key += [str(i) for i in the_args[1:]]
key.append(str(the_kwargs))
str(fname),
str(the_args[1:]),
tuple(the_kwargs.items())
])

return "_".join(key)
return str(hash(tp))

return generate_key


def clean_string(data):
nfkd_form = unicodedata.normalize('NFKD', data.strip())
source = u"".join([c for c in nfkd_form if not unicodedata.combining(c)])
def clean_string(text):

try:
nfd_form = unicodedata.normalize('NFD', text.strip().lower())
except:
return text

cleaned_str = u''.join(x for x in nfd_form if unicodedata.category(x)[0] == 'L' or x == ' ')

return cleaned_str

return source.strip().lower()

class SingletonMixin(object):
"""
Expand Down

0 comments on commit c28435f

Please sign in to comment.