Made the caches.flush_attr_cache more comprehensive also for attribute values.
This commit is contained in:
parent
005b969425
commit
ffbc1ad0e7
1 changed files with 14 additions and 7 deletions
|
|
@ -36,14 +36,18 @@ def hashid(obj):
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
try:
|
try:
|
||||||
date, idnum = _GA(obj, "db_date_created"), _GA(obj, "id")
|
date, idnum = _GA(obj, "db_date_created"), _GA(obj, "id")
|
||||||
if not idnum or not date:
|
|
||||||
# this will happen if setting properties on an object
|
|
||||||
# which is not yet saved
|
|
||||||
return None
|
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
# this happens if hashing something like ndb. We have to
|
try:
|
||||||
# rely on memory adressing in this case.
|
# maybe a typeclass, try to go to dbobj
|
||||||
date, idnum = "Nondb", id(obj)
|
obj = _GA(obj, "dbobj")
|
||||||
|
date, idnum = _GA(obj, "db_date_created"), _GA(obj, "id")
|
||||||
|
except AttributeError:
|
||||||
|
# this happens if hashing something like ndb. We have to
|
||||||
|
# rely on memory adressing in this case.
|
||||||
|
date, idnum = "InMemory", id(obj)
|
||||||
|
if not idnum or not date:
|
||||||
|
# this will happen if setting properties on an object which is not yet saved
|
||||||
|
return None
|
||||||
# build the hashid
|
# build the hashid
|
||||||
hid = "%s-%s-#%s" % (_GA(obj, "__class__"), date, idnum)
|
hid = "%s-%s-#%s" % (_GA(obj, "__class__"), date, idnum)
|
||||||
_SA(obj, "_hashid", hid)
|
_SA(obj, "_hashid", hid)
|
||||||
|
|
@ -269,6 +273,7 @@ if _ENABLE_LOCAL_CACHES:
|
||||||
"""
|
"""
|
||||||
global _ATTR_CACHE
|
global _ATTR_CACHE
|
||||||
try:
|
try:
|
||||||
|
_ATTR_CACHE[hashid(obj)][attrname].no_cache=True
|
||||||
del _ATTR_CACHE[hashid(obj)][attrname]
|
del _ATTR_CACHE[hashid(obj)][attrname]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
@ -279,6 +284,8 @@ if _ENABLE_LOCAL_CACHES:
|
||||||
"""
|
"""
|
||||||
global _ATTR_CACHE
|
global _ATTR_CACHE
|
||||||
if obj:
|
if obj:
|
||||||
|
for attrname, attrobj in _ATTR_CACHE[hashid(obj)].items():
|
||||||
|
attrobj.no_cache = True
|
||||||
del _ATTR_CACHE[hashid(obj)]
|
del _ATTR_CACHE[hashid(obj)]
|
||||||
else:
|
else:
|
||||||
# clean cache completely
|
# clean cache completely
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue