def refresh(self): Image.ImageSink.refresh(self) self.sapi = Shutterfly(self.username, self.password) albums = self.sapi.getAlbums() if not albums.has_key(self.album): self.salbum = self.sapi.createAlbum(self.album) else: self.salbum = albums[self.album] self.sphotos = self.salbum.getPhotos()
class ShutterflySink(Image.ImageSink): _name_ = _("Shutterfly") _description_ = _("Synchronize your Shutterfly photos") _module_type_ = "sink" _icon_ = "shutterfly" _configurable_ = True def __init__(self, *args): Image.ImageSink.__init__(self) self.update_configuration( username = "", password = "", album = "" ) self.sapi = None self.salbum = None self.sphotos = None def _get_raw_photo_url(self, photoInfo): return photoInfo.url def _get_photo_info(self, id): if self.sphotos.has_key(id): return self.sphotos[id] else: return None def _get_photo_formats(self): return ("image/jpeg", ) def refresh(self): Image.ImageSink.refresh(self) self.sapi = Shutterfly(self.username, self.password) albums = self.sapi.getAlbums() if not albums.has_key(self.album): self.salbum = self.sapi.createAlbum(self.album) else: self.salbum = albums[self.album] self.sphotos = self.salbum.getPhotos() def get_all(self): return self.sphotos.keys() def get(self, LUID): #Image.ImageSink.get(self, LUID) sphoto = self.sphotos[LUID] f = Photo.Photo(URI=sphoto.url) f.set_open_URI(sphoto.url) f.set_UID(LUID) return f def delete(self, LUID): """ Delete a photo by ID Deleting a photo invalidates album length and photo index values. We must reload the photos (or do something else...) """ if not self.sphotos.has_key(LUID): log.warn("Photo does not exist") return try: self.salbum.deletePhoto(self.sphotos[LUID]) except Exception, e: raise Exceptions.SyncronizeError("Shutterfly Delete Error - Try Again.") self.sphotos = self.salbum.getPhotos()
class ShutterflySink(Image.ImageSink): _name_ = _("Shutterfly") _description_ = _("Synchronize your Shutterfly photos") _module_type_ = "sink" _icon_ = "shutterfly" _configurable_ = True def __init__(self, *args): Image.ImageSink.__init__(self) self.update_configuration(username="", password="", album="") self.sapi = None self.salbum = None self.sphotos = None def _get_raw_photo_url(self, photoInfo): return photoInfo.url def _get_photo_info(self, id): if self.sphotos.has_key(id): return self.sphotos[id] else: return None def _get_photo_formats(self): return ("image/jpeg", ) def refresh(self): Image.ImageSink.refresh(self) self.sapi = Shutterfly(self.username, self.password) albums = self.sapi.getAlbums() if not albums.has_key(self.album): self.salbum = self.sapi.createAlbum(self.album) else: self.salbum = albums[self.album] self.sphotos = self.salbum.getPhotos() def get_all(self): return self.sphotos.keys() def get(self, LUID): #Image.ImageSink.get(self, LUID) sphoto = self.sphotos[LUID] f = Photo.Photo(URI=sphoto.url) f.set_open_URI(sphoto.url) f.set_UID(LUID) return f def delete(self, LUID): """ Delete a photo by ID Deleting a photo invalidates album length and photo index values. We must reload the photos (or do something else...) """ if not self.sphotos.has_key(LUID): log.warn("Photo does not exist") return try: self.salbum.deletePhoto(self.sphotos[LUID]) except Exception, e: raise Exceptions.SyncronizeError( "Shutterfly Delete Error - Try Again.") self.sphotos = self.salbum.getPhotos()