当前位置: 首页>>代码示例>>Python>>正文


Python Image.query方法代码示例

本文整理汇总了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]}))
开发者ID:ee382,项目名称:connexus,代码行数:9,代码来源:connexus.py

示例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')
开发者ID:Labgoo,项目名称:stashboard,代码行数:12,代码来源:admin.py

示例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))
开发者ID:IanChilds,项目名称:ButtonsAndLace,代码行数:14,代码来源:album_slideshow.py

示例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('/')
开发者ID:IanChilds,项目名称:ButtonsAndLace,代码行数:14,代码来源:delete_albums.py

示例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))
开发者ID:grevian,项目名称:FaceSite,代码行数:18,代码来源:gallery.py

示例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})
开发者ID:Labgoo,项目名称:stashboard,代码行数:19,代码来源:api.py

示例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))
开发者ID:IanChilds,项目名称:ButtonsAndLace,代码行数:23,代码来源:add_album.py

示例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
开发者ID:jipvazoj,项目名称:ProyectoMasterKevin,代码行数:6,代码来源:methods.py

示例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
开发者ID:jipvazoj,项目名称:ProyectoMasterKevin,代码行数:8,代码来源:methods.py

示例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

开发者ID:georgefs,项目名称:ezselector,代码行数:25,代码来源:dump_img.py


注:本文中的models.Image.query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。