def bookmark(post_id, comment_id=None, text=None): try: try: posts.bookmark(post_id, comment_id, text) return xmpp_template('bookmark_sent', post_id=post_id, comment_id=comment_id) except BookmarkExists: posts.unbookmark(post_id, comment_id) return xmpp_template('bookmark_cancel_sent', post_id=post_id, comment_id=comment_id) except PostNotFound: return xmpp_template('post_not_found', post_id=post_id) except CommentNotFound: return xmpp_template('comment_not_found', post_id=post_id, comment_id=comment_id) except RecommendationError: return xmpp_template('post_bookmark_denied', post_id=post_id) except (PostAuthorError, SubscribeError): return xmpp_template('post_denied', post_id=post_id)
def unbookmark(id): comment_id = env.request.args('comment_id') posts.unbookmark(id, comment_id) return Response(redirect=env.request.referer)
def unbookmark_comment(id, comment_id): posts.unbookmark(id, comment_id)
def unbookmark_post(id): posts.unbookmark(id, None)