本文整理汇总了Python中torlite.model.mpost.MPost.query_most_pic方法的典型用法代码示例。如果您正苦于以下问题:Python MPost.query_most_pic方法的具体用法?Python MPost.query_most_pic怎么用?Python MPost.query_most_pic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类torlite.model.mpost.MPost
的用法示例。
在下文中一共展示了MPost.query_most_pic方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PycateIndexHandler
# 需要导入模块: from torlite.model.mpost import MPost [as 别名]
# 或者: from torlite.model.mpost.MPost import query_most_pic [as 别名]
class PycateIndexHandler(BaseHandler):
def initialize(self):
self.init()
self.mpost = MPost()
self.mcat = MCatalog()
self.mpycate = MPycateMCatalog()
self.minfo = MInfor()
def get(self, input=''):
if input == '':
self.index()
else:
self.render('html/404.html')
def index(self):
cstr = tools.get_uuid()
self.set_cookie('user_pass', cstr)
t1 = self.mpycate.get_qian2('01')
s1 = self.format_cat(t1, 1)
t2 = self.mpycate.get_qian2('02')
s2 = self.format_cat(t2, 2)
t3 = self.mpycate.get_qian2('03')
s3 = self.format_cat(t3, 3)
t4 = self.mpycate.get_qian2('04')
s4 = self.format_cat(t4, 4)
t5 = self.mpycate.get_qian2('05')
s5 = self.format_cat(t5, 5)
t6 = self.mpycate.get_qian2('06')
s6 = self.format_cat(t6, 6)
kwd = {
's1': s1,
's2': s2,
's3': s3,
's4': s4,
's5': s5,
's6': s6,
'parentid': '0000',
'parentlist': self.mpycate.get_parent_list(),
'cookie_str': cstr
}
self.render('index/index.html',
kwd=kwd,
userinfo=self.userinfo,
catalog_info=self.mcat.query_all(by_order=True),
view=self.mpost.query_most_pic(20),
)
def format_cat(self, input, sig):
'''
根据分类,生成不同的区域
'''
headstr = '''<div class="panel panel-info" style="width:90%"><div class="panel-heading">
<span class="glyphicon glyphicon-th-large"></span>
<span id="title_{sig1}"></span>
<span><a href='/list/{catid1}'>{catname1}</a></span>
</div>
<ul class="list-group">
'''
outstr = ''
for rec_cat in input:
# 记录的数目
if rec_cat.catid == rec_cat.parentid:
headstr = headstr.format(sig1=sig, catid1=rec_cat.catid, catname1=rec_cat.catname)
continue
recout = self.minfo.get_cat_recs_count(rec_cat.catid)
if recout > 0:
recout = str(recout)
else:
recout = 0
tmpstr = '''<li class="list-group-item">
<a href="/list/{scatid}" title="{scatname}">{scatname}</a>
<span style="color:#666;font-size:12px">({scount})</span></li>
'''.format(scatid=rec_cat.catid, scatname=rec_cat.catname, scount=recout)
outstr += tmpstr
outstr += '''</ul></div>'''
outstr = headstr + outstr
return (outstr)