def post(self, post_id): message = self.request.get("message") p = Post.by_id(BLOG_KEY, post_id) if not message: error = "inform a valid comment, please" self.render("post-permalink.html", p=p, new_comment_error=error) else: comment = Comment(parent=p.key, owner=self.user.key, content=message) comment.put() self.redirect('/blog/%s' % post_id)
def post(self, post_id): text = self.request.get('comment-text') params = dict(comment_text=text) post, post_id = get_post_from_request(self, post_id) if not post: return self.abort(404, "No post associated with request") params['post_id'] = post_id if text: # Creating comment comment = Comment(user=self.user.key, post=post.key, content=text) comment.put() self.redirect_to_uri("permalink", post_id=post_id) else: params['comment_error'] = "Comment cannot be empty" self.render_page(**params)