本文整理汇总了Python中model.Comment.recent_comments方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.recent_comments方法的具体用法?Python Comment.recent_comments怎么用?Python Comment.recent_comments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Comment
的用法示例。
在下文中一共展示了Comment.recent_comments方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: recent_comments
# 需要导入模块: from model import Comment [as 别名]
# 或者: from model.Comment import recent_comments [as 别名]
def recent_comments(self):
comments = []
for comment in Comment.recent_comments(10):
text = markdown.markdown(
comment.text,
output_format='html5',
safe_mode='replace',
)
comments.append((
text,
comment.user.id(),
comment.user.get().username,
comment.photo.id(),
comment.format_date()
))
return comments
示例2: get
# 需要导入模块: from model import Comment [as 别名]
# 或者: from model.Comment import recent_comments [as 别名]
def get(self):
user_id, user = self.get_user()
start = self.request.get('start')
logging.info('start: %s', start)
if not start:
start = 0
else:
start = int(start)
if start > 1000000:
start = 0
if start == 0:
before = 0
after = 10
else:
before = start - 10
after = start + 10
comments = list(Comment.recent_comments(10, start))
logging.info(len(comments))
more_old = '' if len(comments) == 10 else 'disabled'
more_new = '' if start > 0 else 'disabled'
data = {
'page_title': 'Comments',
'user': user,
'comments': comments,
'before': before,
'after': after,
'more_old': more_old,
'more_new': more_new,
}
self.render('comments.html', **data)