1. Mikhail Korobov
  2. django-cache-utils
Issue #4 new

Add patch to make compatible with python 2.4 and unicode strings

Anonymous created an issue

{{{

!python

diff -r 16e1595a404f gvein/lib/cache_utils/utils.py --- a/gvein/lib/cache_utils/utils.py Wed Dec 07 02:01:20 2011 +0200 +++ b/gvein/lib/cache_utils/utils.py Wed Dec 07 10:08:03 2011 +0200 @@ -1,6 +1,6 @@ #from hashlib import md5 import md5 -from django.utils.encoding import smart_unicode +from django.utils.encoding import smart_unicode, smart_str

CONTROL_CHARACTERS = set([chr(i) for i in range(0, 33)]) CONTROL_CHARACTERS.add(chr(127)) @@ -22,9 +22,9 @@ def _args_to_unicode(args, kwargs): key = "" if args: - key += smart_unicode(args) + key += smart_str(args) if kwargs: - key += smart_unicode(kwargs) + key += smart_str(kwargs) return key

}}}

Comments (1)

  1. Anonymous
    @@ -12,8 +12,11 @@
         """
         key = ''.join([c for c in key if c not in CONTROL_CHARACTERS])
         if len(key) > max_length:
    -        hash = md5(key).hexdigest()
    -        key = key[:max_length-33]+'-'+hash
    +        m = md5.new()
    +        m.update(key)
    +        hash = m.hexdigest()
    +        #hash = md5(key).hexdigest()
    +        key = key[:max_length - 33] + '-' + hash
         return key
    
  2. Log in to comment