本文整理汇总了Python中models.Image.query方法的典型用法代码示例。如果您正苦于以下问题:Python Image.query方法的具体用法?Python Image.query怎么用?Python Image.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Image
的用法示例。
在下文中一共展示了Image.query方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import query [as 别名]
def get(self):
lat = float(self.request.get('lat'))
lng = float(self.request.get('lng'))
images = Image.query().fetch()
images = sorted(images, key=lambda img: distance_on_unit_sphere(img.lat, img.lng, lat, lng))
self.response.headers['Content-Type'] = 'application/json'
return self.response.out.write(json.dumps({"images": [img.key.id() for img in images]}))
示例2: get
# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import query [as 别名]
def get(self):
td = {
"statuses_selected": True,
"action": "create",
"url": "/admin/api/v1/statuses",
"images": Image.query().fetch(200),
}
td.update(site.default_template_data())
self.render(td, 'admin/status_create.html')
示例3: get
# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import query [as 别名]
def get(self):
album_key = ndb.Key(urlsafe=self.request.get('key'))
photos = Image.query(ancestor=album_key).fetch()
blob_keys = []
for photo in photos:
blob_keys.append(images.get_serving_url(photo.image_blob))
template_values = {'is_admin': users.is_current_user_admin(),
'album': album_key.get(),
'blob_keys': blob_keys,
'photos': photos}
self.response.out.write(template.render(path, template_values))
示例4: get
# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import query [as 别名]
def get(self):
if users.is_current_user_admin():
photos = Image.query().fetch()
albums = Album.query().fetch()
for photo in photos:
photo_key = ndb.Key(urlsafe=photo.ukey())
photo_key.delete()
for album in albums:
album_key = ndb.Key(urlsafe=album.ukey())
album_key.delete()
self.redirect('/')
示例5: get
# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import query [as 别名]
def get(self):
cursor = self.request.get("cursor", None)
if cursor:
cursor = Cursor(urlsafe=cursor)
ctx = {}
image_q = Image.query().order(-Image.uploaded)
image_list, next_curs, more = image_q.fetch_page(20, start_cursor=cursor)
ctx['images'] = list(image_list)
if more:
ctx['cursor'] = next_curs.urlsafe()
template = JINJA_ENVIRONMENT.get_template('templates/gallery.html')
self.response.write(template.render(ctx))
示例6: get
# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import query [as 别名]
def get(self, version):
if not self.valid_version(version):
self.error(404, "API Version %s not supported" % version)
return
host = self.request.headers.get('host', 'nohost')
images = []
for img in Image.query().fetch(1000):
image = {
"url": "http://" + host + "/images/" + img.path,
"icon_set": img.icon_set,
"name": img.slug,
}
images.append(image)
self.json({"images": images})
示例7: get
# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import query [as 别名]
def get(self):
if not users.is_current_user_admin():
self.redirect('/')
else:
album, photos = None, None
try:
album_key = ndb.Key(urlsafe=self.request.get('key'))
photos = Image.query(ancestor=album).fetch()
album = album_key.get()
except:
pass
upload_new_photo_url = blobstore.create_upload_url('/add-photo')
upload_new_thumbnail_url = blobstore.create_upload_url('/add-thumbnail')
template_values = {'is_admin': users.is_current_user_admin(),
'album': album,
'photos': photos,
'upload_new_photo_url': upload_new_photo_url,
'upload_new_thumbnail_url': upload_new_thumbnail_url}
self.response.out.write(template.render(path, template_values))
示例8: getPublicPhotos
# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import query [as 别名]
def getPublicPhotos():
i = Image()
photos = i.query(Image.public==True).fetch()
return photos
示例9: getUsersPhotos
# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import query [as 别名]
def getUsersPhotos(user):
u = User()
u.user = user
i = Image()
photos = i.query(Image.user==u.user).fetch()
return photos
示例10: open
# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import query [as 别名]
from google.appengine.datastore.datastore_query import Cursor
from models import Image
from share_libs.serve import cache_image
f = open('/tmp/cursor', 'w+')
imgs, cursor, more = Image.query().fetch_page(1000)
while True:
try:
imgs, cursor, more = Image.query().fetch_page(1000, start_cursor=cursor)
f.write(cursor.urlsafe() +"\n")
f.flush()
print cursor
for img in imgs:
if not img.cached_image:
try:
img.cached_image = cache_image(img.image).replace('localhost', '192.168.33.15')
print img.cached_image
img.put()
except Exception as e:
print e
except Exception as e:
pass