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