Commit f231b419 authored by Vincent Pelletier's avatar Vincent Pelletier

Make preventive actions to avoid exceptions raised by python-memcached. This...

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.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14365 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 17085854
......@@ -124,11 +124,15 @@ if memcache is not None:
# 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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment