本文整理汇总了Python中post.Post.find_by_subject方法的典型用法代码示例。如果您正苦于以下问题:Python Post.find_by_subject方法的具体用法?Python Post.find_by_subject怎么用?Python Post.find_by_subject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类post.Post
的用法示例。
在下文中一共展示了Post.find_by_subject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import find_by_subject [as 别名]
def post(self, post_subject):
# If any user does not logged in redirect to homepage
if not self.user:
self.redirect("/login")
post_to_delete = Post.find_by_subject(post_subject)
# If post couldn't find redirect 404 page
if not post_to_delete:
self.error(404)
return self.render('404.html')
if not self.user.owner_of(post_to_delete):
self.redirect("/")
else:
# delete post likes
for like in post_to_delete.postlike_set:
like.delete()
# delete comment and comment likes
for comment in post_to_delete.comment_set:
for like in comment.commentlike_set:
like.delete()
comment.delete()
# finally delete the post's itself
post_to_delete.delete()
self.redirect('/')
示例2: get
# 需要导入模块: from post import Post [as 别名]
# 或者: from post.Post import find_by_subject [as 别名]
def get(self, post_subject):
post = Post.find_by_subject(post_subject)
if not post:
self.error(404)
return self.render('404.html')
self.render("/posts/post.html", post=post, errors=None)