本文整理汇总了Python中google.appengine.ext.blobstore.BlobInfo.gql方法的典型用法代码示例。如果您正苦于以下问题:Python BlobInfo.gql方法的具体用法?Python BlobInfo.gql怎么用?Python BlobInfo.gql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类google.appengine.ext.blobstore.BlobInfo
的用法示例。
在下文中一共展示了BlobInfo.gql方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: upload_post_processing
# 需要导入模块: from google.appengine.ext.blobstore import BlobInfo [as 别名]
# 或者: from google.appengine.ext.blobstore.BlobInfo import gql [as 别名]
def upload_post_processing():
file = request.files.data.filename
# validate file is image format
if mimetypes.guess_type(file)[0].split('/')[0] != 'image':
# delete non-image file types
BlobInfo.gql("WHERE filename = :fname", fname=file).get().delete()
return template('upload_error.html')
response.set_cookie('img', file, path='/')
redirect('/upload_success')
示例2: get_image
# 需要导入模块: from google.appengine.ext.blobstore import BlobInfo [as 别名]
# 或者: from google.appengine.ext.blobstore.BlobInfo import gql [as 别名]
def get_image(image):
"""
set header content type.
query blobstore, filter on filename, and execute query -> get BlobInfo
open BlobReader with BlobInfo keyand read data -> return raw data
"""
#TODO: consider some kind of validation of file type and content?
blob_info = BlobInfo.gql("WHERE filename = :fname", fname=image).get()
response.content_type = blob_info.content_type
return blobstore.BlobReader(blob_info).read()
示例3: filter
# 需要导入模块: from google.appengine.ext.blobstore import BlobInfo [as 别名]
# 或者: from google.appengine.ext.blobstore.BlobInfo import gql [as 别名]
def filter(filename, chrm, start, end, filters):
out = []
indexname = "%s.index.%s.json" % (filename, chrm)
log("attempting to load from m cache")
index = memcache.get(indexname)
if index is None:
log("mcache loading failed, loading from blobstore")
blob = BlobInfo.gql("where filename = '%s'" % (indexname)).get()
if not blob is None:
log("mcache loading failed, parseing from json")
index = json.load(blob.open())
log("adding to memcache")
try:
if not memcache.add(indexname, index):
logging.error("Memcache set failed.")
except ValueError:
logging.info("Memcache value error.")
if not index is None:
leftbound = bisect_left(index, start)
rightbound = bisect_right(index, end)
for edge in index[leftbound:rightbound]:
# if edge < start:
# continue
# if edge["Pos1"] > end:
# break
includeme = False
if filters != False:
for filter in filters:
if edge["Type"] == filter["type"] and int(edge["Score"]) >= int(filter["minscore"]):
includeme = True
break
else:
includeme = True
if includeme == True:
out.append(edge)
return out