[Erp5-report] r29531 - /erp5/trunk/products/ERP5Type/Tool/MemcachedTool.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Oct 9 15:50:01 CEST 2009
Author: kazuhiko
Date: Fri Oct 9 15:50:00 2009
New Revision: 29531
URL: http://svn.erp5.org?rev=29531&view=rev
Log:
* use Quoted Printable encode instead of 'removing invalid characters' to encode keys for memcached.
* add a global prefix that makes it possible to share the same memcached with different ERP5 instances.
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=29531&r1=29530&r2=29531&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Tool/MemcachedTool.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Tool/MemcachedTool.py [utf8] Fri Oct 9 15:50:00 2009
@@ -32,6 +32,7 @@
from Products.ERP5Type import Permissions, _dtmldir
from AccessControl import ClassSecurityInfo
from Globals import DTMLFile
+from quopri import encodestring
MEMCACHED_TOOL_MODIFIED_FLAG_PROPERTY_ID = '_v_memcached_edited'
@@ -42,14 +43,12 @@
def encodeKey(key):
"""
- Encode the key. The current encoding is not very good
- since it is not bijective. Implementing a bijective
- encoding is required.
+ Encode the key like 'Quoted Printable'.
"""
- # Memcached refuses characters which are below ' ' (included) in
- # ascii table. Just strip them here to avoid the raise.
- return ''.join([x for x in key if ord(x) > \
- MEMCACHED_MINIMUM_KEY_CHAR_ORD])
+ # According to the memcached's protocol.txt, the key cannot contain
+ # control characters and white spaces.
+ return encodestring(key, True).replace('\n', '').replace('\r', '')
+
memcached_dict_pool = local()
if memcache is not None:
# Real memcache tool
@@ -299,6 +298,9 @@
plugin_path
relative_url of dedicated Memcached Plugin
"""
+ global_prefix = getattr(self, 'erp5_site_global_id', '')
+ if global_prefix:
+ key_prefix = '%s_%s' % (global_prefix, key_prefix)
return SharedDict(self._getMemcachedDict(plugin_path), prefix=key_prefix)
else:
More information about the Erp5-report
mailing list