本文整理汇总了Python中models.Image.gql方法的典型用法代码示例。如果您正苦于以下问题:Python Image.gql方法的具体用法?Python Image.gql怎么用?Python Image.gql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Image
的用法示例。
在下文中一共展示了Image.gql方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: images_exists
# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import gql [as 别名]
def images_exists(self, hash):
images = Image.gql("WHERE sha1_hash = :h", h = hash)
for image in images:
if image.sha1_hash == hash:
return True
return False
示例2: post
# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import gql [as 别名]
def post(self,subdomain=None):
product_id=self.request.get("product_id")
upload_files = self.get_uploads('file') # 'file' is file upload field in the form
blob_info = upload_files[0]
for i in range(0,5):
count = Image.gql("WHERE __key__=KEY('Image','%s-%s') LIMIT 1" % (product_id,i)).count()
if count == 0:
image = Image(blob_key=str(blob_info.key()),key_name='%s-%s' %(product_id, i),user=subdomain)
image.put()
self.redirect('/serve/%s-%s' % (product_id,i))
break;
self.response.out.write('Maximum number of images for this product id, please delete one before uploading.'),
示例3: get
# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import gql [as 别名]
def get(self, hash):
res = self.request.get('res')
r = res.split('x')
if len(hash) <> 40:
self.wrong_url()
return
# The default is the empty string.
# Check for empty resolution string
if res == '' or '' in r or len(r) < 2:
self.wrong_url()
return
# check if dimensions are at least 100x100
if len(r[0]) < 3 or len(r[1]) < 3:
self.wrong_url()
return
# check if dimensions are numbers at all
try:
int(r[0])
int(r[1])
except ValueError:
self.wrong_url()
return
images = Image.gql("WHERE sha1_hash = :h ORDER BY filenumber",
h = hash) # hash is only first 40 chars
if images.count() == 0:
self.wrong_url()
return
template_values = { 'images': images,
'hash' : hash,
'w' : r[0],
'h' : r[1]
}
path = os.path.join(os.path.dirname(__file__), 'templates/problem.html')
self.response.out.write(template.render(path, template_values))