[Erp5-report] r14365 - /erp5/trunk/products/ERP5Type/Tool/MemcachedTool.py

nobody at svn.erp5.org nobody at svn.erp5.org
Fri May 4 14:51:23 CEST 2007


Author: vincent
Date: Fri May  4 14:51:23 2007
New Revision: 14365

URL: http://svn.erp5.org?rev=14365&view=rev
Log:
Make preventive actions to avoid exceptions raised by python-memcached. This fixes a symptom (*not* the real cause) of the "can loggin with space-padded username" bug.

Modified:
    erp5/trunk/products/ERP5Type/Tool/MemcachedTool.py

Modified: erp5/trunk/products/ERP5Type/Tool/MemcachedTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Tool/MemcachedTool.py?rev=14365&r1=14364&r2=14365&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Tool/MemcachedTool.py (original)
+++ erp5/trunk/products/ERP5Type/Tool/MemcachedTool.py Fri May  4 14:51:23 2007
@@ -124,11 +124,15 @@
       # We need to register in this function too to be able to flush cache at 
       # transaction end.
       self._register()
+      # Memcached refuses characters which are below ' ' (inclued) in
+      # ascii table. Just strip them here to avoid the raise.
+      stripped_key = ''.join([x for x in key if ord(x) > \
+                              MEMCACHED_MINIMUM_KEY_CHAR_ORD])
       result = self.local_cache.get(key, MARKER)
       if result is MARKER:
-        result = self.memcached_connection.get(key)
+        result = self.memcached_connection.get(stripped_key)
         if result is None:
-          raise KeyError, 'Key %s not found.' % (key, )
+          raise KeyError, 'Key %s (was %s) not found.' % (stripped_key, key)
         self.local_cache[key] = result
       return result
   




More information about the Erp5-report mailing list