Revision: 56
Author: jimsaku
Date: Sat Apr 6 06:09:17 2013
Log: Fix for issue 23.
Also made it easier to fetch individual Photosets by ID (if that's the only
parameter passed to the constructor, the rest of the Photoset information is
fetched from the API).
http://code.google.com/p/flickrpy/source/detail?r=56
Modified:
/trunk/flickr.py
=======================================
--- /trunk/flickr.py Sat Apr 6 05:49:26 2013
+++ /trunk/flickr.py Sat Apr 6 06:09:17 2013
@@ -383,11 +383,25 @@
return data.rsp.galleries.gallery
class Photoset(object):
- """A Flickr photoset."""
+ """A Flickr photoset.
+
+ If constructed with just an ID, the rest of the data about the
Photoset is
+ fetched from the API.
+
+ """
- def __init__(self, id, title, primary, photos=0, description='', \
+ def __init__(self, id, title=None, primary=None, photos=0,
description='', \
secret='', server=''):
self.__id = id
+
+ if not title and not primary:
+ method = 'flickr.photosets.getInfo'
+ data = _doget(method, photoset_id=
self.id)
+ title = data.rsp.photoset.title.text
+ primary = Photo(data.rsp.photoset.primary)
+ description = data.rsp.photoset.description.text
+ count = data.rsp.photoset.photos
+
self.__title = title
self.__primary = primary
self.__description = description
@@ -412,6 +426,14 @@
data = _doget(method, photoset_id=
self.id)
photos = data.rsp.photoset.photo
p = []
+
+ # If there's only one photo in the set, the API returns a single
photo,
+ # not a list
+ try:
+ iter(photos)
+ except TypeError:
+ photos = [photos]
+
for photo in photos:
p.append(Photo(
photo.id, title=photo.title,
secret=photo.secret, \
server=photo.server))