Use object ID in default cache key adapter, and add string key adapter
authorThierry Florac <thierry.florac@onf.fr>
Thu, 29 Mar 2018 10:44:44 +0200
changeset 161 2e3f8f762158
parent 160 db952e3e1583
child 162 b275180f783b
Use object ID in default cache key adapter, and add string key adapter
src/pyams_utils/zodb.py
--- a/src/pyams_utils/zodb.py	Thu Mar 29 10:43:33 2018 +0200
+++ b/src/pyams_utils/zodb.py	Thu Mar 29 10:44:44 2018 +0200
@@ -73,7 +73,12 @@
 
 @adapter_config(context=object, provides=ICacheKeyValue)
 def object_key_adapter(obj):
-    return '{0!r}'.format(obj)
+    return str(id(obj))
+
+
+@adapter_config(context=str, provides=ICacheKeyValue)
+def string_key_adapter(obj):
+    return obj
 
 
 #