next/previous fields are lists in APIv2, but single photo ids in APIv1.

This commit is contained in:
sneakypete81 2013-04-20 12:12:40 +01:00
parent fc234096f2
commit 7501c8ca77

View file

@ -87,13 +87,23 @@ class Photo(OpenPhotoObject):
**kwds)["result"] **kwds)["result"]
value = {} value = {}
if "next" in result: if "next" in result:
# Workaround for APIv1
if not isinstance(result["next"], list):
result["next"] = [result["next"]]
value["next"] = [] value["next"] = []
for photo in result["next"]: for photo in result["next"]:
value["next"].append(Photo(self._openphoto, photo)) value["next"].append(Photo(self._openphoto, photo))
if "previous" in result: if "previous" in result:
# Workaround for APIv1
if not isinstance(result["previous"], list):
result["previous"] = [result["previous"]]
value["previous"] = [] value["previous"] = []
for photo in result["previous"]: for photo in result["previous"]:
value["previous"].append(Photo(self._openphoto, photo)) value["previous"].append(Photo(self._openphoto, photo))
return value return value
def transform(self, **kwds): def transform(self, **kwds):