当前位置: 首页>>代码示例>>Python>>正文


Python Category.get方法代码示例

本文整理汇总了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)
开发者ID:aviatorBeijing,项目名称:ptpy,代码行数:60,代码来源:board.py

示例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
开发者ID:hooops,项目名称:PersonalWebsite,代码行数:12,代码来源:blog.py

示例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})
开发者ID:flreey,项目名称:private-navigation,代码行数:12,代码来源:category.py

示例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())
开发者ID:DlutCS,项目名称:nserver_py,代码行数:13,代码来源:home.py

示例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
开发者ID:DlutCS,项目名称:nserver_py,代码行数:19,代码来源:admin.py

示例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
开发者ID:hooops,项目名称:PersonalWebsite,代码行数:5,代码来源:blog.py

示例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)
开发者ID:hooops,项目名称:PersonalWebsite,代码行数:6,代码来源:blog.py

示例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'})
开发者ID:flreey,项目名称:private-navigation,代码行数:8,代码来源:category.py

示例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})
开发者ID:flreey,项目名称:private-navigation,代码行数:4,代码来源:category.py


注:本文中的models.category.Category.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。