本文整理汇总了Python中category.Category.get_by_folder_id方法的典型用法代码示例。如果您正苦于以下问题:Python Category.get_by_folder_id方法的具体用法?Python Category.get_by_folder_id怎么用?Python Category.get_by_folder_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类category.Category
的用法示例。
在下文中一共展示了Category.get_by_folder_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: go_categories
# 需要导入模块: from category import Category [as 别名]
# 或者: from category.Category import get_by_folder_id [as 别名]
def go_categories(xmldoc):
categorieslist = xmldoc.getElementsByTagName('category')
for s in categorieslist:
category_id = s.attributes['id'].value
name = s.childNodes[0].nodeValue
try:
parent_id = s.attributes['parentId'].value
except:
parent_id = None
print name
print Category.get_by_folder_id(parent_id)
print category_id
c = Category(name=name.replace('"', '"'),
parent=Category.get_by_folder_id(parent_id),
folder_id=category_id)
print c
c.save()
示例2: go_items
# 需要导入模块: from category import Category [as 别名]
# 或者: from category.Category import get_by_folder_id [as 别名]
def go_items(xmldoc):
itemlist = xmldoc.getElementsByTagName('offer')
for s in itemlist :
product_id = s.attributes['id'].value
price = s.getElementsByTagName('price')[0].childNodes[0].nodeValue
name = s.getElementsByTagName('name')[0].childNodes[0].nodeValue
vendor = s.getElementsByTagName('vendor')[0].childNodes[0].nodeValue
if s.getElementsByTagName('description')[0].childNodes:
description = s.getElementsByTagName('description')[0].childNodes[0].nodeValue
else:
description = ''
category_id = s.getElementsByTagName('categoryId')[-1].childNodes[0].nodeValue
producer = Producer.get_or_create(vendor)
category = Category.get_by_folder_id(category_id)
if category:
Item(category=category,
producer=producer,
name=name,
price=float(price),
description=description,
product_id=product_id,
).save()