src/pyams_utils/cache.py
changeset 172 8476b679fcab
parent 165 f124b8ffaa50
child 206 5ac9be953a8f
--- a/src/pyams_utils/cache.py	Fri Apr 13 12:23:18 2018 +0200
+++ b/src/pyams_utils/cache.py	Thu Apr 26 16:00:38 2018 +0200
@@ -35,4 +35,7 @@
 
 @adapter_config(context=IPersistent, provides=ICacheKeyValue)
 def persistent_cache_key_adapter(obj):
-    return str(int.from_bytes(obj._p_oid, byteorder='big'))
+    if obj._p_oid:
+        return str(int.from_bytes(obj._p_oid, byteorder='big'))
+    else:  # unsaved object
+        return str(id(obj))