本文整理汇总了Python中models.Comment.select_all方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.select_all方法的具体用法?Python Comment.select_all怎么用?Python Comment.select_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Comment
的用法示例。
在下文中一共展示了Comment.select_all方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import select_all [as 别名]
def get(self):
params = self.request.url_params
print params
category = params[0]
which = params[1]
article, comment, comments, user = None, None, None, None
if category == 'article':
# delete article and all related comments
old_article = Article.select_one('created_at=?', which)
article = old_article
old_article.delete()
old_comments = Comment.select_all('article_id=?', article.id)
comments = old_comments
if old_comments:
for comment in old_comments:
comment.delete()
elif category == 'user':
old_user = User.select_one('id=?', which)
user = old_user
old_user.delete()
elif category == 'comment':
old_comment = Comment.select_one('id=?', which)
comment = old_comment
old_comment.delete()
return self.render('_delete.html', article=article, comment=comment, \
comments=comments, user=user)
示例2: post
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import select_all [as 别名]
def post(self):
"""Comment for about page."""
comment = self.request.get_argument('comment', '')
# insert into db, and load page again
u_id = self.get_current_user()
user_d = User.select_one('id=?', u_id)
created_at = int(time.time())
comment_d = Comment(article_id=222222222, username=user_d.name, \
content=comment, created_at=created_at)
comment_d.insert()
comments = Comment.select_all('article_id=?', 222222222)
return self.render('about.html', comments=comments)