本文整理汇总了Python中models.category.Category.query方法的典型用法代码示例。如果您正苦于以下问题:Python Category.query方法的具体用法?Python Category.query怎么用?Python Category.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.category.Category
的用法示例。
在下文中一共展示了Category.query方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models.category import Category [as 别名]
# 或者: from models.category.Category import query [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)
示例2: get
# 需要导入模块: from models.category import Category [as 别名]
# 或者: from models.category.Category import query [as 别名]
def get(self):
loginTitle = ""
loginURL = ""
user = users.get_current_user()
if user:
loginTitle = "logout"
loginURL= users.create_logout_url('/')
else:
loginTitle = "login"
loginURL= users.create_login_url('/')
photos = {}
categories = Category.query().order(Category.categoryName)
for category in categories:
photos[category.key] = category.picture.get()
templateVars = {
"title" : "Manage Categories",
"loginURL" : loginURL,
"loginTitle": loginTitle,
"categories": categories,
"photos": photos
}
self.render_template("/templates/adminCategories.html", templateVars)
示例3: get
# 需要导入模块: from models.category import Category [as 别名]
# 或者: from models.category.Category import query [as 别名]
def get(self):
template = JINJA_ENVIRONMENT.get_template('/templates/publicHome.html')
photos = {}
categories = Category.query().order(Category.categoryName)
for category in categories:
photos[category.key] = category.picture.get()
templateVars = {
"title" : "Nick Michael's Fine Gallery",
"categories": categories,
"photos": photos}
self.response.write(template.render(templateVars))
示例4: post
# 需要导入模块: from models.category import Category [as 别名]
# 或者: from models.category.Category import query [as 别名]
def post(self):
artpieceKeyString = self.request.get('editArtKey')
artpieceID = int(artpieceKeyString)
artistString = self.request.get('editArtist')
categoriesString = self.request.get('editCategories')
name = self.request.get('editName')
price = self.request.get('editPrice')
priceDisplay = "$" + '{:20,.2f}'.format(Decimal(price))
itemNumber = self.request.get('editItemNumber')
width = self.request.get('editWidth')
height = self.request.get('editHeight')
depth = self.request.get('editDepth')
weight = self.request.get('editWeight')
description = self.request.get('editProductDescription')
colors = self.request.get('editColors')
mediums = self.request.get('editMediums')
masterItemNum = self.request.get('editMasterArtNum')
pictureName = self.request.get('editProductPhotoName')
#find related objects to tie to this artpiece
artistNameList=artistString.split(" ")
artistFirstName=artistNameList[0]
artistLastName=artistNameList[-1]
artist = Artist.query(Artist.firstName==artistFirstName, Artist.lastName==artistLastName).get()
categories = []
categoriesList = categoriesString.split(",")
for categoryString in categoriesList:
category = Category.query(Category.categoryName==categoryString.strip()).get()
categories.append(category)
masterArtPiece = ArtPiece.query(ArtPiece.itemNumber==masterItemNum).get()
photo = File.query(File.file_name==pictureName.upper()).get()
#get the artpiece based on the key and update all fields accordingly
artpiece = ArtPiece.get_by_id(artpieceID)
artpiece.artist = artist.key
artpiece.categories = []
for category in categories:
artpiece.categories.append(category.key)
artpiece.colors = colors
artpiece.depth = depth
artpiece.description = description
artpiece.height = height
artpiece.itemNumber = itemNumber
if masterArtPiece:
artpiece.masterArtPiece = masterArtPiece.key
artpiece.slaveArtFlag = True
masterArtPiece.masterArtFlag = True
masterArtPiece.put()
artpiece.mediums = mediums
artpiece.name = name
artpiece.picture = photo.key
artpiece.price = price
artpiece.priceDisplay = priceDisplay
artpiece.uploaded_by=users.get_current_user()
artpiece.weight = weight
artpiece.width = width
artpiece.put()
artpiece.add_to_search_index()
message = "Successfully updated artpiece record: " + artpiece.name
self.response.write(message)