Add .pk check to Tag/AttributeHandler when returning cached Tags and Attributes.

This commit is contained in:
Griatch 2016-11-03 20:12:07 +01:00
parent b3d432e0c6
commit fb7e5762a6
2 changed files with 2 additions and 2 deletions

View file

@ -251,7 +251,7 @@ class AttributeHandler(object):
if key:
cachekey = "%s-%s" % (key, category)
attr = _TYPECLASS_AGGRESSIVE_CACHE and self._cache.get(cachekey, None)
if attr:
if attr and hasattr(attr, "pk") and attr.pk:
return [attr] # return cached entity
else:
query = {"%s__id" % self._model : self._objid,

View file

@ -140,7 +140,7 @@ class TagHandler(object):
if key:
cachekey = "%s-%s" % (key, category)
tag = _TYPECLASS_AGGRESSIVE_CACHE and self._cache.get(cachekey, None)
if tag:
if tag and hasattr(tag, "pk") and tag.pk:
return [tag] # return cached entity
else:
query = {"%s__id" % self._model : self._objid,