本文整理汇总了Python中model.Comment.get_comments方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.get_comments方法的具体用法?Python Comment.get_comments怎么用?Python Comment.get_comments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Comment
的用法示例。
在下文中一共展示了Comment.get_comments方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from model import Comment [as 别名]
# 或者: from model.Comment import get_comments [as 别名]
def get(self):
page = int(self.get_argument('page', 1))
if self.get_argument('act', '') == 'delete':
Comment.delete_comment_by_id(int(self.get_argument('id', 0)))
pagesize = 20
rtn = Comment.get_comments(pagesize=pagesize)
self.datamap['comments'] = rtn[1]
self.datamap['count'] = rtn[0]
self.datamap['pagecount'] = int(math.ceil(float(rtn[0]) / pagesize))
self.write(render_admin.comment(self.datamap))
示例2: get
# 需要导入模块: from model import Comment [as 别名]
# 或者: from model.Comment import get_comments [as 别名]
def get(self, nodeid, topicid):
t_key = 't-%s-%s' % (str(nodeid), str(topicid))
t_obj = Topic.get_by_key(t_key)
if not t_obj or t_obj.has_key('hide'):
self.set_status(404)
self.echo('error.html', {
'page': '404',
'title': "Can't find out this URL",
'h2': 'Oh, my god!',
'msg': 'Something seems to be lost...'
})
return
if t_obj['cnum']:
cnum = int(t_obj['cnum'])
from_id = int(self.get_argument('id', '1'))
if from_id>1 and from_id%EACH_PAGE_COMMENT_NUM!=1:
self.redirect('/'+t_key)
return
to_id = from_id + EACH_PAGE_COMMENT_NUM - 1
if to_id > cnum:
to_id = cnum
c_objs = Comment.get_comments(t_key, from_id, to_id)
else:
c_objs = None
from_id = to_id = cnum = 0
self.echo('topicdetail.html', {
'title': t_obj['title'] + ' - ' + t_obj['nodename'],
'description':'description',
't_obj': t_obj,
'c_objs': c_objs,
'from_id': from_id,
'to_id': to_id,
'cnum': cnum,
'newest_node': Node.get_newest(),
'recent_node': Node.get_recent_node(),
'hot_node': Node.get_hot_node(),
'recent_topic_objs': Commomkvdb.get_comment_topic_by_keys('recent-topic-home'),
'comment_topic_objs': Commomkvdb.get_comment_topic_by_keys('recent-comment-topic-home'),
}, layout='_layout.html')
示例3: get
# 需要导入模块: from model import Comment [as 别名]
# 或者: from model.Comment import get_comments [as 别名]
def get(self, nodeid, topicid):
topic_key = '%s-%s' % (nodeid, topicid)
t_obj = Topic.get_by_key_name(topic_key)
if not t_obj:
self.error(404)
self.echo('error.html', {
'page': '404',
'title': "Can't find out this URL",
'h2': 'Oh, my god!',
'msg': 'Something seems to be lost...'
})
return
if t_obj.cnum:
from_id = int(self.request.get('id', '1'))
if from_id>1 and from_id%EACH_PAGE_COMMENT_NUM!=1:
self.redirect('/t-'+topic_key)
return
to_id = from_id + EACH_PAGE_COMMENT_NUM - 1
if to_id > t_obj.cnum:
to_id = t_obj.cnum
c_objs = Comment.get_comments(topic_key, from_id, to_id)
else:
c_objs = None
from_id = to_id = cnum = 0
self.echo('topicdetail.html', {
'title': t_obj.title + ' - ' + t_obj.node.name,
'description':'description',
't_obj': t_obj,
'c_objs': c_objs,
'from_id': from_id,
'to_id': to_id,
'newest_node': Node.get_newest(),
'recent_node': Node.get_recent_node(),
'hot_node': Node.get_hot_node(),
'recent_topic_objs': KeyStrValue.get_topic_key_title('recent-topic-home'),
'reply_topic_objs': KeyStrValue.get_topic_key_title('recent-reply-topic'),
}, layout='_layout.html')