More elaborate catch of the .pk property for Attributes and Tags.

This commit is contained in:
Griatch 2016-11-03 20:18:08 +01:00
parent fb7e5762a6
commit afa4e74322
2 changed files with 10 additions and 2 deletions

View file

@ -251,7 +251,11 @@ class AttributeHandler(object):
if key:
cachekey = "%s-%s" % (key, category)
attr = _TYPECLASS_AGGRESSIVE_CACHE and self._cache.get(cachekey, None)
if attr and hasattr(attr, "pk") and attr.pk:
if attr and (not hasattr(attr, "pk") and attr.pk is None):
# clear out Attributes deleted from elsewhere. We must search this anew.
attr = None
del self._cache[cachekey]
if attr:
return [attr] # return cached entity
else:
query = {"%s__id" % self._model : self._objid,

View file

@ -140,7 +140,11 @@ class TagHandler(object):
if key:
cachekey = "%s-%s" % (key, category)
tag = _TYPECLASS_AGGRESSIVE_CACHE and self._cache.get(cachekey, None)
if tag and hasattr(tag, "pk") and tag.pk:
if tag and (not hasattr(tag, "pk") and tag.pk is None):
# clear out Tags deleted from elsewhere. We must search this anew.
tag = None
del self._cache[cachekey]
if tag:
return [tag] # return cached entity
else:
query = {"%s__id" % self._model : self._objid,