本文整理汇总了Python中category.Category.save方法的典型用法代码示例。如果您正苦于以下问题:Python Category.save方法的具体用法?Python Category.save怎么用?Python Category.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类category.Category
的用法示例。
在下文中一共展示了Category.save方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: categories
# 需要导入模块: from category import Category [as 别名]
# 或者: from category.Category import save [as 别名]
def categories():
if request.method == 'GET':
# return an html list of all the categories
return render_template('category/index.html', categories=Category.all(), success=True)
elif request.method == 'POST':
# create new category based on the posted id
params = request.get_json()
new_category_id = int(params['id'])
fields = {key: "" for key, value in form_fields.iteritems()}
new_category = Category(new_category_id, fields)
new_category.save()
return 'OK', 200
else:
return 'error', 400
示例2: learn
# 需要导入模块: from category import Category [as 别名]
# 或者: from category.Category import save [as 别名]
def learn(self):
# for each directory in the document root...
for category_name in os.listdir(self.docroot):
category_path = os.path.join(self.docroot, category_name)
# if the category is a file (not a directory), then skip it
if os.path.isfile(category_path):
continue
category = Category(self.database, category_name, self.stop_list)
self.categories[category_name] = category
# call the function to handle the directory/category
category.categorize(category_path)
category.save()
示例3: go_categories
# 需要导入模块: from category import Category [as 别名]
# 或者: from category.Category import save [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()