Resolves problems in storing/restoring tickerhandler keys. Resolves #997.

This commit is contained in:
Griatch 2016-06-24 18:14:11 +02:00
parent b014df00de
commit 03ef093d36
2 changed files with 37 additions and 26 deletions

View file

@ -278,6 +278,11 @@ def unpack_dbobj(item):
obj = item[3] and _TO_MODEL_MAP[item[1]].objects.get(id=item[3])
except ObjectDoesNotExist:
return None
except TypeError:
if hasattr(item, "pk"):
# this happens if item is already an obj
return item
return None
# even if we got back a match, check the sanity of the date (some
# databases may 're-use' the id)
return _TO_DATESTRING(obj) == item[2] and obj or None