本文整理匯總了Python中models.category.Category.get方法的典型用法代碼示例。如果您正苦於以下問題:Python Category.get方法的具體用法?Python Category.get怎麽用?Python Category.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models.category.Category
的用法示例。
在下文中一共展示了Category.get方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get
# 需要導入模塊: from models.category import Category [as 別名]
# 或者: from models.category.Category import get [as 別名]
def get(self,key):
uri = self.request.uri
request = {}
pin = Pin()
pin_keys = pin.getByKeyValues("board",key)
pin_count = len(pin_keys)
query = {}
query['q'] = "board:%s" % key
query['start'] = "0"
query['rows'] = globalSetting['max_index_pin_rows']
query['sort'] = "createTime"
if "page" in uri:
request = urldecode(uri)
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']
#print request['page']
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
board = Board()
user = User()
category = Category()
board_data = board.get(key)
b_user = user.getDetail(board_data['user'])
b_category = category.get(board_data['category'])
b_keys = board.getByKeyValues("user", board_data['user'])
if key in b_keys:
b_keys.remove(key)
b_boards = board.all(b_keys)
self.render('board_pins_list.html',f_board = self.formatFollowBoardData(key), b_boards= b_boards,b_category = b_category,b_user=b_user,user=self.currentUserInfo(),board = board.get(key),marks=marks)
示例2: get_blog_detail
# 需要導入模塊: from models.category import Category [as 別名]
# 或者: from models.category.Category import get [as 別名]
def get_blog_detail(cls, blog_id):
blog = cls.get(cls.id == blog_id)
blogtags = BlogTags.get(BlogTags.blog_id == blog.id)
tag = Tags.get(Tags.id == blogtags.tags_id).tag
blogcategory = BlogCategory.get(BlogCategory.blog_id == blog_id)
category = Category.get(Category.id == blogcategory.category_id).category
return blog, tag, category
示例3: put
# 需要導入模塊: from models.category import Category [as 別名]
# 或者: from models.category.Category import get [as 別名]
def put(self, cat_id):
form = ApiCategoryForm(request.form)
if form.validate():
c = Category.get(cat_id)
if c.user_id != session['user_id']:
return jsonify({'code': 2, 'message': 'has no permission to modify the category'})
else:
form.fill_data_to_instance(c)
return jsonify(code=0, data=c.json)
return jsonify({'code': 1, 'message': form.errors})
示例4: get
# 需要導入模塊: from models.category import Category [as 別名]
# 或者: from models.category.Category import get [as 別名]
def get(self, cid):
if not cid or not Category.get(cid):
abort(404)
if cid == 1:
return redirect(url_for('main.home'))
news_header = News.get_by_category(cid, order='create_time desc', start=0, limit=7)
news_latest = News.get_by_category(cid, order='create_time desc', start=7)
news_popular = News.get_by_category(cid, order='read_count desc', start=0)
loginform = LoginForm()
regform = RegisterForm()
return render_template('index.html', **locals())
示例5: category_retrieve
# 需要導入模塊: from models.category import Category [as 別名]
# 或者: from models.category.Category import get [as 別名]
def category_retrieve():
id = request.args.get('id', 0)
if id:
category = Category.get(id)
if not category:
return error(404, 'category not exist')
return category
# start = request.args.get('start', 0)
# limit = int(request.args.get('limit', PAGE_LIMIT))
# category還要start??,
data = {}
data['start'] = 0
data['data'] = Category.get_all()
data['count'] = len(data['data'])
return data
示例6: get_category
# 需要導入模塊: from models.category import Category [as 別名]
# 或者: from models.category.Category import get [as 別名]
def get_category(cls, blog_id):
category_id = cls.get(cls.blog_id == blog_id).category_id
return Category.get(Category.id == category_id).category
示例7: get_blog_by_category
# 需要導入模塊: from models.category import Category [as 別名]
# 或者: from models.category.Category import get [as 別名]
def get_blog_by_category(cls, category):
category_id = Category.get(Category.category == category).id
blogs_categorys = BlogCategory.select(BlogCategory.blog_id).where(BlogCategory.category_id == category_id)
return cls.select().filter(cls.id << blogs_categorys)
示例8: delete
# 需要導入模塊: from models.category import Category [as 別名]
# 或者: from models.category.Category import get [as 別名]
def delete(self, cat_id):
c = Category.get(cat_id)
if c:
c.delete()
return jsonify({'code': 0})
return jsonify({'code': 1, 'message': 'category not exist'})
示例9: get
# 需要導入模塊: from models.category import Category [as 別名]
# 或者: from models.category.Category import get [as 別名]
def get(self, cat_id):
return jsonify({'code': 0, 'data':Category.get(cat_id).json})