editcomment.py 文件源码

python
阅读 14 收藏 0 点赞 0 评论 0

项目:Multi-User-Blog 作者: thetreythomas 项目源码 文件源码
def post(self, postID, commentID):
        key = db.Key.from_path('Post', int(postID), parent = blog_key())
        post = db.get(key)

        if self.request.get("save"):
            comment = Comments.get_by_id(int(commentID))
            if self.user and comment:
                comment = Comments.get_by_id(int(commentID))
                if comment.author.name == self.user.name:
                    comment.content = self.request.get("content")
                    comment.put()
                    time.sleep(0.2)
                    self.redirect("/blog/%s" % str(post.key().id()))
                else:
                    save_error = "Only the author of the comment can make changes."
                    self.render("editcomment.html", comment = comment, save_error = save_error)

        if self.request.get("cancel"):
            self.redirect("/blog/%s" % str(post.key().id()))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号