本文整理汇总了Python中models.category.Category.getCats方法的典型用法代码示例。如果您正苦于以下问题:Python Category.getCats方法的具体用法?Python Category.getCats怎么用?Python Category.getCats使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.category.Category
的用法示例。
在下文中一共展示了Category.getCats方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models.category import Category [as 别名]
# 或者: from models.category.Category import getCats [as 别名]
def get(self,cat_key):
if cat_key == 'All':
self.redirect('/')
else:
uri = self.request.uri
request = {}
pin = Pin()
pin_keys = pin.getByCat(cat_key)
pin_count = len(pin_keys)
query = {}
query['q'] = "category:%s" % cat_key
query['start'] = "0"
query['rows'] = globalSetting['max_index_pin_rows']
query['sort'] = "createTime"
if "page" in uri:
request = urldecode(uri)
print request
page = int(request['page'])
query['start'] = query['rows']*page
if pin_count < query['rows']*page:
return ''
pin_data = pin.solr(query)
#print len(pin_data)
marks_dict = pin.formatPins(pin_data)
if request:
#print request
callback_result = {
'filter':'pin:index',
'pins':marks_dict
}
callback_response = "%s(%s)" % (request['callback'],json.dumps(callback_result))
self.set_header("Content-Type", "text/html; charset=utf-8")
return self.write(callback_response)
else:
marks = ''
for _mark_t in marks_dict:
marks = self.render_string('mark.html',mark=_mark_t)+marks
if marks == '':
marks = """
<div class="pin category wfc isotope-item" style="margin-bottom: 15px; position: absolute; left: 0px; top: 0px; -webkit-transform: translate3d(0px, 0px, 0px); ">
NO PINS
</div>
"""
category = Category()
cats = category.getCats()
self.render('index.html',user=self.currentUserInfo(),marks=marks,cats = cats,urlname = cat_key)