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


Python Image.all方法代码示例

本文整理汇总了Python中models.Image.all方法的典型用法代码示例。如果您正苦于以下问题:Python Image.all方法的具体用法?Python Image.all怎么用?Python Image.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Image的用法示例。


在下文中一共展示了Image.all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import all [as 别名]
    def get(self, hash, extension=None):
        q = Album.all().filter('hash =', hash)
        album = q.get()
        if album:
            if extension:
                return self.error(404)
            
            q = Image.all().filter('album =', album)
            return self.response.out.write(render_template('album.html', {
                'name': album.name,
                'images': q,
            }))

        q = Image.all().filter('hash =', hash)
        image = q.get()
        if image:
            if not extension:
                return self.response.out.write(render_template('image.html',
                    { 'image': image }))
            elif image.extension == extension:
                return write_image(self, image.image_data, extension)
            else:
                return self.error(404)
        
        return self.error(404)
开发者ID:chosak,项目名称:restful-gallery,代码行数:27,代码来源:app.py

示例2: delete

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import all [as 别名]
    def delete(self, album_id, image_id, extension=None):
        """DELETE handler for gallery images.

        URL pattern: /albums/${album_id}/images/${image_id}
        
        If image exists, returns 200 OK. 
        If image doesn't exist, returns 404 NOT FOUND.

        Returns 401 UNAUTHORIZED to all calls if authorization fails.
        """
        q = Album.all().filter('album_id =', album_id)
        album = q.get()
        if not album:
            return self.error(404)

        q = Image.all().filter('album =', album).filter('image_id =', image_id)
        image = q.get()
        if not image:
            return self.error(404)
        
        if extension and extension != image.extension:
            return self.error(404)

        if not config.DEMO_MODE:
            image.delete()
开发者ID:chosak,项目名称:restful-gallery,代码行数:27,代码来源:app.py

示例3: get

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import all [as 别名]
    def get(self, group_id, image_name):
        filename, effect = parse_image_name(image_name)

        group = get_image_group_or_404(self, group_id)

        img = Image.all().filter("file_name", filename).filter("group", group).get()
        if not img or not img.data:
            #            raise NotFound()
            self.abort(404)

        if not effect:
            response_data = img.data.data
            response_type = img.mime_type
        else:
            square_file = os.path.join(os.path.dirname(__file__), "server-images", effect + ".png")

            f = overlay_png(png.Reader(file=open(square_file, "rb")), png.Reader(bytes=img.data.data))

            response_data = f.getvalue()
            response_type = "image/png"  # We know overlay_png returns PNG

        #        return Response(response=response_data,
        #                        content_type=response_type,
        #                        headers={'Cache-Control' : 'private, max-age=31536000'})
        self.response.headers["Content-Type"] = response_type.encode("utf")
        self.response.headers["Cache-Control"] = "private, max-age=31536000"
        self.response.write(response_data)
开发者ID:andreyvit,项目名称:mockko,代码行数:29,代码来源:handlers.py

示例4: get_images_by_tags

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import all [as 别名]
 def get_images_by_tags(self, tags):
     """Returns the url of an image in the index that has tags"""
     DEBUG('get_images_by_tags: %s' % tags)
     ltags = [tag.lower() for tag in tags]
     q = Image.all()
     for tag in ltags:
         q.filter('tags =', tag)
     return q.fetch(100)
开发者ID:dforsyth,项目名称:gif-wrappy,代码行数:10,代码来源:wrappy.py

示例5: get

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import all [as 别名]
 def get(self):
     if self.request.headers.get('X-AppEngine-Cron', 'false') == 'true':
         now = datetime.datetime.now()
         half_hour_ago = now - datetime.timedelta(minutes=30)
         for image in Image.all().filter('date <', half_hour_ago):
             image_blob = blobstore.BlobInfo.get(image.blob_key)
             if image_blob:
                     image_blob.delete()
             image.delete()
开发者ID:guilhermechapiewski,项目名称:meme-ios-backend,代码行数:11,代码来源:image.py

示例6: _list_tags

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import all [as 别名]
 def _list_tags(self, blip, startend, arguments):
     q = Image.all()
     images = q.fetch(2000)
     tag_list = []
     for image in images:
         tag_list.extend(image.tags)
     tag_set = set(tag_list)
     range = blip.range(startend[0], startend[1])
     range.replace(', '.join(tag_set))
开发者ID:dforsyth,项目名称:gif-wrappy,代码行数:11,代码来源:wrappy.py

示例7: _rmtag

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import all [as 别名]
 def _rmtag(self, blip, startend, arguments):
     url = arguments[0]
     tags = arguments[1:]
     q = Image.all()
     q.filter('url =', url)
     images = q.fetch(1)
     for image in images:
         image.tags = [tag for tag in image.tags if tag not in tags]
         image.put()
开发者ID:dforsyth,项目名称:gif-wrappy,代码行数:11,代码来源:wrappy.py

示例8: get

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import all [as 别名]
    def get(self):
        td = {
            "statuses_selected": True,
            "action": "create",
            "url": "/admin/api/v1/statuses",
            "images": Image.all().fetch(200),
            }

        td.update(site.default_template_data())
        self.render(td, 'admin/status_create.html')
开发者ID:Homefinder,项目名称:stashboard,代码行数:12,代码来源:admin.py

示例9: get

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import all [as 别名]
    def get(self):
        images = Image.all().order('-inserted').fetch(image_count+1)

        more = True if len(images) > image_count else False

        vals = {
            'images'      : images,
            'image_count' : image_count if more else len(images),
            'more'        : more,
        }
        self.template( 'image-list.html', vals, 'admin' );
开发者ID:ranginui,项目名称:kohacon,代码行数:13,代码来源:image.py

示例10: get

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import all [as 别名]
 def get(self):
     "Responds to GET requests with the admin interface"
     # query the datastore for images 
     images = Image.all().order("date").fetch(1000)
     context = {
         "images": images,
         "total_width": len(images) * IMAGE_WIDTH
         }
     # calculate the template path
     path = os.path.join(os.path.dirname(__file__), 'templates',
         'index.html')
     # render the template with the provided context
     self.response.out.write(template.render(path, context))
开发者ID:jamslevy,项目名称:portfolio,代码行数:15,代码来源:index.py

示例11: get

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import all [as 别名]
    def get(self):
        if 'tabselect' in self.request.GET:
           tabselect = self.request.get('tabselect')
        else:
           tabselect='general'

        self.render_template('admin',
            {'news_list' : NewsArticleNew.all().order('-date'),
             'talk_list' : TalkNew.all().order('-date'),
             'hack_list' : Hack.all().order('-date'),
             'image_list' : Image.all(),
             'image_height' : self.image_height,
             'image_width' : self.image_width,
             'members': Member.all(),
             'message' : self.admin_message,
             'tabselect':tabselect})
开发者ID:Man-UP,项目名称:website,代码行数:18,代码来源:handlers.py

示例12: get

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import all [as 别名]
    def get(self):
        "Responds to GET requets with the admin interface"
        images = Image.all()
        images.order("-date")

        # we need the logout url for the frontend
        logout = users.create_logout_url("/")

        # prepare the context for the template
        context = {
            "images": images,
            "logout": logout,
        }
        template = jinja_environment.get_template('index.html')
        # render the template with the provided context
        self.response.out.write(template.render(context))
开发者ID:proglottis,项目名称:appengine-image-host,代码行数:18,代码来源:backend.py

示例13: get

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import all [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.all().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:Tradeshift,项目名称:stashboard,代码行数:19,代码来源:api.py

示例14: posts

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import all [as 别名]
def posts(postkey):
    p = Post.all()
    if postkey != 'all':
        key = Key(postkey)
        p.filter("__key__ =",key)
    postList = ['defualtfirst']
    for post in p.run():
        tmpPost = MultiDict()
        tmpPost['title'] = post.title
        tmpPost['msg'] = post.msg
        q = Image.all()
        q.filter("post_id",post.key())
        for i,image in enumerate(q.run()):
            tmpPost['image'+str(i)] = image.encoded_string
        postList.append(tmpPost)
    tmpOutput = MultiDict()
    tmpOutput['res'] = postList
    return jsonify(tmpOutput)
开发者ID:lolyzor,项目名称:pushnotifications-server,代码行数:20,代码来源:main.py

示例15: _metrics

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import all [as 别名]
    def _metrics(self, blip, startend, arguments):
        q = Image.all()
        images = q.fetch(2000) # fetch needs a 'limit'
        user_dict = {}
        tag_list = []
        image_total = len(images)
        for image in images:
            tag_list.extend(image.tags)
            if image.submitter not in user_dict:
                user_dict[image.submitter] = 1
            else:
                user_dict[image.submitter] = user_dict[image.submitter] + 1
        
        metrics_message = '\n%d images in the database (%d unique tags):\n' % (image_total, len(set(tag_list)))
        for user, count in user_dict.iteritems():
            metrics_message = '%s\n%s: %d (%f%%)' % (metrics_message, user, count, (float(count * 100) / image_total))

        range = blip.range(startend[0], startend[1])
        range.replace(metrics_message)
开发者ID:dforsyth,项目名称:gif-wrappy,代码行数:21,代码来源:wrappy.py


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