def _get_album_by_invitation(self, u_url): """ returns: Save() instance, or None is case of any error. """ # sanity check of the given url if u_url.get_query('uname') is None or u_url.get_query('uname') == '': return None if u_url.get_query('id') is None or u_url.get_query('id') == '': return None if u_url.get_query('target') != 'ALBUM': return None # convert the email url to picasa feed url authkey = u_url.get_query('authkey') n_url = PhotosOfAlbum(u_url.get_query('uname'), u_url.get_query('id')) if authkey is not None: n_url.set_query(authkey=authkey) n_url.set_query(max_results='0') # retrieve the album feed to get album parameters client = picasaclient.PicasaClient() client.set_proxy(self.get_network_settings()) try: feed = client.get_feed(uri=n_url.get_url()) if not isinstance(feed, picasaclient.AlbumFeed): return None except picasaclient.RequestError: return None # create node from feed parameters instead of entry album = Album(attrs=dict([['user', feed.user], ['nick', feed.nickname], ['thumbnail', feed.icon], ['title', feed.title], ['gid', feed.gphoto_id], ['numphotos', feed.numphotos], ['authkey', authkey]])) return Save(album)
def __getattribute__(self, name): if name == 'label': return "%s (%s)" %(self.title, self.numphotos) elif name == 'url': u = PhotosOfAlbum(self.user, self.gid) if self.authkey: u.set_query(authkey=self.authkey) return u elif name == 'menus': m = Content.__getattribute__(self, name) u = TagsOfAlbum(self.user, self.gid) if self.authkey: u.set_query(authkey=self.authkey) m.append(FolderMenu(self.get_str(30208), u)) if not self.flags: user = User(attrs=dict([['user',self.user], ['nick',self.nick], ['thumbnail', self.icon]])) m.append(ActionMenu(self.get_str(30207) % self.nick, Save(user))) return m else: return super(Album, self).__getattribute__(name)