Renamed <object>._trovebox to <object>._client, to match API classes.

Changed _type to a class attribute.
This commit is contained in:
sneakypete81 2013-09-09 18:08:11 +01:00
parent 3cfc090dd0
commit 7a7b43afc7
6 changed files with 66 additions and 67 deletions

View file

@ -8,11 +8,12 @@ from .photo import Photo
class Activity(TroveboxObject):
""" Representation of an Activity object """
def __init__(self, trovebox, json_dict):
_type = "activity"
def __init__(self, client, json_dict):
self.data = None
self.type = None
TroveboxObject.__init__(self, trovebox, json_dict)
self._type = "activity"
TroveboxObject.__init__(self, client, json_dict)
self._update_fields_with_objects()
def _update_fields_with_objects(self):
@ -20,7 +21,7 @@ class Activity(TroveboxObject):
# Update the data with photo objects
if self.type is not None:
if self.type.startswith("photo"):
self.data = Photo(self._trovebox, self.data)
self.data = Photo(self._client, self.data)
else:
raise NotImplementedError("Unrecognised activity type: %s"
% self.type)
@ -32,8 +33,8 @@ class Activity(TroveboxObject):
Requests the full contents of the activity.
Updates the activity's fields with the response.
"""
result = self._trovebox.get("/activity/%s/view.json" %
self.id, **kwds)["result"]
result = self._client.get("/activity/%s/view.json" %
self.id, **kwds)["result"]
# TBD: Why is the result enclosed/encoded like this?
result = result["0"]