# HG changeset patch # User Thierry Florac # Date 1524751238 -7200 # Node ID 8476b679fcabf7df960e5cde32a23121e7b195b1 # Parent d6c77b2b5c4b51bc84dc00dfadb48f1a52ce1e61 Check OID when getting cache key for persistent object diff -r d6c77b2b5c4b -r 8476b679fcab src/pyams_utils/cache.py --- 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))