If an object is passed as a parameter, extract its ID.

This allows things like:
   photos = client.photos.list()
   client.photos.delete(photos)
This commit is contained in:
sneakypete81 2012-09-04 09:08:57 +01:00
parent 21c38c53cb
commit fafeb70ec1
7 changed files with 53 additions and 28 deletions

View file

@ -1,4 +1,4 @@
from openphoto_http import OpenPhotoHttp, OpenPhotoError
from errors import *
from objects import Tag
class ApiTags:
@ -21,13 +21,13 @@ class ApiTag:
def delete(self, tag, **kwds):
""" Delete a tag """
tag = Tag(self._client, {"id": tag})
if not isinstance(tag, Tag):
tag = Tag(self._client, {"id": tag})
tag.delete(**kwds)
def update(self, tag, **kwds):
""" Update a tag """
tag = Tag(self._client, {"id": tag})
if not isinstance(tag, Tag):
tag = Tag(self._client, {"id": tag})
tag.update(**kwds)
return tag