def render_friend_list(playlist_id, people=None): """Render a template containing a list of friends. If people is None, lookup the list of people from memcache. """ if people is None: try: people = memcacheutils.lookup_people_given_playlist(playlist_id) except KeyError: return "" memcacheutils.lookup_editing_status(playlist_id, people) people.sort(key=lambda p: p["display_name"]) return webutils.render_to_string("friend_list.html", dict(friends=people))
def write_playlist(handler, yt_service, playlist_id, notify_playlist_listeners): """Construct a video_list template and send it via the Channel API. The reason you have to pass the notify_playlist_listeners() function is so that I can avoid a dependency nightmare. """ (playlist, entries) = fetch_feed_and_entries( yt_service.GetYouTubePlaylistVideoFeed, playlist_id=playlist_id) template_params = {"video_list": prepare_playlist(entries), "button_name": "Remove", "class_name": "playlist-item", "playlist_id": playlist_id} html = webutils.render_to_string("video_list.html", template_params) message = dict(action="updateElement", id="playlist", html=html) notify_playlist_listeners(playlist_id, message) handler.response.out.write("OK")