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


Python Category.children方法代码示例

本文整理汇总了Python中model.Category.children方法的典型用法代码示例。如果您正苦于以下问题:Python Category.children方法的具体用法?Python Category.children怎么用?Python Category.children使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在model.Category的用法示例。


在下文中一共展示了Category.children方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getCategory

# 需要导入模块: from model import Category [as 别名]
# 或者: from model.Category import children [as 别名]
def getCategory(current_category_key):
    current_category = None
    lineage = []
    
    try:
        current_category = Category.get(db.Key(current_category_key))
        lineage = [Category.get(key) for key in current_category.lineage]
    except db.BadKeyError:
        pass
    except AttributeError:
        pass
    
    #todo - massive oppurtunity for optimization
    retval = current_category.key().__str__() + ',' + current_category.name + ';'
    
    for category in lineage:
        retval += category.key().__str__() + ',' + category.name + ','
    retval += ';'
    
    for category in Category.children(current_category):
        retval += category.key().__str__() + ',' + category.name + ','
    
    print 'Content-Type: text/plain;charset=UTF-8'
    print ''
    print retval
开发者ID:bgourlie,项目名称:barterhub,代码行数:27,代码来源:async_server.py

示例2: get

# 需要导入模块: from model import Category [as 别名]
# 或者: from model.Category import children [as 别名]
    def get(self):
        current_category_key = self.request.get("category")
        current_category = None
        lineage = []

        try:
            current_category = Category.get(db.Key(current_category_key))
            lineage = [Category.get(key) for key in current_category.lineage]
        except db.BadKeyError:
            pass
        except AttributeError:
            pass

        child_categories = Category.children(current_category)
        self.tpl_vars["current_category"] = current_category
        self.tpl_vars["child_categories"] = child_categories
        self.tpl_vars["lineage"] = lineage
        path = os.path.join(os.path.dirname(__file__), "templates/admin/index.html")
        self.response.out.write(template.render(path, self.tpl_vars))
开发者ID:bgourlie,项目名称:barterhub,代码行数:21,代码来源:admin_request_handler.py


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