def get_comment(cid, auth, owner=False): comment = Comment.load(cid) if comment is None: raise HTTPError(http.NOT_FOUND) if owner: if auth.user != comment.user: raise HTTPError(http.FORBIDDEN) return comment
def kwargs_to_comment(kwargs, owner=False): comment = Comment.load(kwargs.get('cid')) if comment is None: raise HTTPError(http.BAD_REQUEST) if owner: auth = kwargs['auth'] if auth.user != comment.user: raise HTTPError(http.FORBIDDEN) return comment