Commits

Lau Bech Lauritzen  committed d33e710

Fixet unicode problems

  • Participants
  • Parent commits 1403e7c

Comments (0)

Files changed (1)

File johnny/cache.py

     def gen_table_key(self, table, db='default'):
         """Returns a key that is standard for a given table name and database alias.
         Total length up to 212 (max for memcache is 250)."""
-        table = str(table)
-        db = str(db)
+        table = unicode(table)
+        db = unicode(db)
         if len(table) > 100:
             table = table[0:68] + self.gen_key(table[68:])
         if db and len(db) > 100:
         """Generate a key from one or more values."""
         key = md5()
         for v in values:
-            key.update(str(v))
+            key.update(v.encode("utf-8") if type(v) == unicode else str(v))
         return key.hexdigest()
 
 class KeyHandler(object):