本文整理匯總了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)