本文整理汇总了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})