本文整理汇总了Python中models.category.Category.put方法的典型用法代码示例。如果您正苦于以下问题:Python Category.put方法的具体用法?Python Category.put怎么用?Python Category.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.category.Category
的用法示例。
在下文中一共展示了Category.put方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models.category import Category [as 别名]
# 或者: from models.category.Category import put [as 别名]
def post(self):
categoryName = self.request.get('categoryName')
photoName = self.request.get('photoName')
#get the photo specified by the user
photo = File.query(File.file_name==photoName.upper()).get()
#check to see if a category with that name already exists
existingCategory = Category.query(Category.categoryName==categoryName).get()
if existingCategory:
#if an category with that name already exists, then update the information with the form data
existingCategory.categoryName=categoryName
existingCategory.picture=photo.key
existingCategory.uploaded_by=users.get_current_user()
existingCategory.put()
existingCategory.add_to_search_index()
message = "Successfully updated category record: " + existingCategory.categoryName
else:
#add a new category entry if no category with that name already exists
category = Category(categoryName=categoryName, picture=photo.key, uploaded_by=users.get_current_user())
category.put()
category.add_to_search_index()
message = "Successfully created category record: " + category.categoryName
self.response.write(message)