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


Python Image.get方法代码示例

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


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

示例1: transfer_s3_structure_to_db

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import get [as 别名]
def transfer_s3_structure_to_db(name, path, parent_directory, is_dir=False):
    if parent_directory is not None:
        par_dir = Directory.get(Directory.key == parent_directory)
    else:
        par_dir = FakeDirectory()
        par_dir.id = None
    if is_dir:
        try:
            Directory.get(Directory.key == path)
            return False
        except DoesNotExist:
            Directory.create(
                name = name,
                key = path,
                parent_directory = par_dir.id
            )
            return True
    else:
        try:
            Image.get(Image.key == path)
            return False
        except DoesNotExist:
            Image.create(
                name = name,
                key = path,
                directory = par_dir.id
            )
            return True
开发者ID:BlaiseGratton,项目名称:DataAnalysisNgin,代码行数:30,代码来源:boto.py

示例2: get_image

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import get [as 别名]
def get_image(id):
    # Get image #id
    try:
        image = Image.get(Image.id == id)
    except Image.DoesNotExist:
        return jsonify(**IMAGE_NOT_FOUND)

    return render_template("image.html", image=image)
开发者ID:KyubiSystems,项目名称:Wisewolf,代码行数:10,代码来源:views.py

示例3: get

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import get [as 别名]
    def get(self):
        item = None
        if self.request.get('key'):
            item = Image.get( self.request.get('key') )

        vals = {
            'item'       : item,
            # this is either new.html or edit.html
            'upload_url' : blobstore.create_upload_url( str(urllib.unquote(self.request.path)) ),
            }
        self.template( 'image-form.html', vals, 'admin' );
开发者ID:ranginui,项目名称:kohacon,代码行数:13,代码来源:image.py

示例4: post

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import get [as 别名]
 def post(self,key):
     try:
         image = Image.get(Key(key))
         post = self.request.POST
         image.name=post['name']
         image.title=post['title']
         image.alt=post['alt']
         image.put()
         self.render_template('editImage',{'image':image})
     except BadKeyError:
         self.render_template('editImage',{'error':"Image Not Found"})
开发者ID:Man-UP,项目名称:website,代码行数:13,代码来源:handlers.py

示例5: post

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import get [as 别名]
 def post(self):
     if not self.has_permission:
         return
     user = self.current_user
     content = self.get_argument('content', None)
     image_ids = self.get_argument('image_ids', None)
     images = []
     if content and len(strip_tags(content)) >= 3:
         tweet = Tweet(content=strip_xss_tags(content), user_id=user.id).save()
         tweet.put_notifier()
         if image_ids:
             image_ids = image_ids.split(',')
             for image_id in image_ids:
                 image_id = int(image_id)
                 image = Image.get(id=image_id)
                 if image:
                     image.tweet_id = tweet.id
                     images.append({
                         'id': image.id,
                         'path': image.path,
                         'width': image.width,
                         'height': image.height,
                         })
         if images != []:
             tweet.has_img = 'true'
         result = {
                     'status'          : 'success',
                     'message'         : '推文创建成功',
                     'content'         : tweet.content,
                     'name'            : tweet.author.name,
                     'nickname'        : tweet.author.nickname,
                     'author_avatar'   : tweet.author.get_avatar(size=48),
                     'author_url'      : tweet.author.url,
                     'author_name'     : tweet.author.name,
                     'author_nickname' : tweet.author.nickname,
                     'tweet_url'       : tweet.url,
                     'created'         : tweet.created,
                     'id'              : tweet.id,
                     'images'          : images,
                 }
         if self.is_ajax:
             return self.write(result)
         self.flash_message(result)
         return self.redirect('/timeline')
     result = {
                 'status': 'error',
                 'message': '推文内容至少 3 字符'
             }
     if self.is_ajax:
         return self.write(result)
     self.flash_message(result)
     return self.redirect('/timeline')
开发者ID:Quasimo,项目名称:collipa,代码行数:54,代码来源:tweet.py

示例6: post

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import get [as 别名]
    def post(self, image_key):
        """<input type="hidden" name="crop[x]" value="0" />
		<input type="hidden" name="crop[y]" value="0" />
		<input type="hidden" name="crop[w]" value="0" />
		<input type="hidden" name="crop[h]" value="0" />"""

        left = float(self.request.POST["crop[x]"])
        top = float(self.request.POST["crop[y]"])
        right = float(self.request.POST["crop[w]"])
        bottom = float(self.request.POST["crop[h]"])

        img = Image.get(image_key)
        img.do_crop(left, top, right, bottom)

        self.redirect("/%s/crop/%s" % (IMAGE_APP_PATH, str(img.key())))
开发者ID:mentat,项目名称:imageapp,代码行数:17,代码来源:views.py

示例7: put

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import get [as 别名]
 def put(self, image_id):
     image_id = int(image_id)
     image = Image.get(id=image_id)
     if not image:
         raise tornado.web.HTTPError(404)
     album_id = self.get_int('album_id', None)
     if not album_id:
         return self.send_error_result(msg=u'没有指定专辑哦')
     album = Album.get(id=album_id)
     if not album:
         return self.send_error_result(msg=u'专辑不存在')
     if album.user_id != self.current_user.id:
         return self.send_error_result(msg=u'此专辑不是您的专辑')
     if image.album_id != album_id:
         image.album_id = album_id
     return self.send_success_result()
开发者ID:ljtyzhr,项目名称:collipa,代码行数:18,代码来源:image.py

示例8: delete_image

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import get [as 别名]
def delete_image(id):
    # Get image #id
    try:
        image = Image.get(Image.id == id)
    except Image.DoesNotExist:
        return jsonify(**IMAGE_NOT_FOUND)

    # TODO: Delete image binary file and thumb
    # Need to check safe path and MIME type first

    # Delete image DB record
    query = Image.delete().where(Image.id == id)
    query.execute()

    # return JSON status OK
    return jsonify(**STATUS_OK)
开发者ID:KyubiSystems,项目名称:Wisewolf,代码行数:18,代码来源:views.py

示例9: post

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import get [as 别名]
 def post(self):
     try:
         item = Image.get( self.request.get('key') ) if self.request.get('key') else None
         if item is not None:
             try:
                 if item.blob:
                     item.blob.delete()
                 item.delete()
                 self.redirect('.')
             except:
                 vals = {
                     'item' : item,
                     'err' : 'There was an error when deleting this image, please try again'
                     }
                 self.template( 'image-del.html', vals, 'admin' );
     except:
         self.redirect('.')
开发者ID:ranginui,项目名称:kohacon,代码行数:19,代码来源:image.py

示例10: image_detail

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import get [as 别名]
def image_detail(imageid):

    """
        function that is when a specific image is requested
        the metadata of the requested image is loaded (if there is one)
        and given to the template
    """

    try: 
        image = Image.get(id=imageid)
        imgfrag = ImageFragment.get(image=image, x=0, y=0, visible=True)
        imgmeta = Metadata.get(imgfrag=imgfrag, namespace="http://www.w3.org/ns/ma-ont#")
        annos = Annotation.get(imgmeta=imgmeta)
        return render_template('image_detail.html', img=image,imgmeta=imgmeta)
    except Imageuri.DoesNotExist:
        flash('Die Bildnummer wurde nicht gefunden. Bitte waehle ein anderes Bild.', 'error')
        return render_template('images.html')
    except ImageFragment.DoesNotExist:
        return render_template('image_detail.html', img=image)
开发者ID:annebaui,项目名称:srimato,代码行数:21,代码来源:views.py

示例11: grab_post

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import get [as 别名]
def grab_post(req):
  """ Gets a post and validates the answers. """
  sec_okay = 1
  image_ans = req.get('word', None)
  image_id = req.get('image_id', None)
  sec_id = req.get('sec_id', None)
  sec_ans = req.get('sec_ans', None) 
  
  truth_file = Image.get(Image.id == image_id)
  with open(truth_file.answer, 'r') as file:
    image_truth = file.readline().strip()
 
  s = Secondary.get(Secondary.id == sec_id)
  known = s.known(2, 0.85)
  if ((image_ans == image_truth) and
      (not known or (known and (s.truth['word'] == sec_ans))) ):
    sec_update(sec_id, sec_ans)    
    return True
  else:
    return False
开发者ID:zatricion,项目名称:nuCAPTCHA,代码行数:22,代码来源:views.py

示例12: delete

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import get [as 别名]
 def delete(self, image_id):
     image = Image.get(id=image_id)
     if not image:
         return self.redirect_next_url()
     if self.current_user.is_admin and image.user_id != self.current_user.id:
         subject = "图片删除通知 - " + config.site_name
         template = (
                 '<p>尊敬的 <strong>%(nickname)s</strong> 您好!</p>'
                 '您在 %(site) 的图片由于违反社区规定而被删除。</p>'
                 ) % {
                         'nickname': image.author.nickname,
                         'site': config.site_name,
                         }
         self.send_email(self, image.author.email, subject, template)
     if image.user_id == self.current_user.id:
         image.remove()
         result = {'status': 'success', 'message': '已成功删除'}
     else:
         result = {'status': 'error', 'message': '你没有权限啊, baby'}
     return self.write(result)
开发者ID:ClayMoreBoy,项目名称:collipa,代码行数:22,代码来源:image.py

示例13: get

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import get [as 别名]
    def get(self, image_key):
        img = Image.get(image_key)

        width = int(self.request.GET.get("width", "300"))

        # If no ratio we need to compute the ratio first thing
        # this is a small performance hit the first time.

        if img.ratio is None:
            thumb = img.get_thumb(width, commit=False)
            img.ratio = float(thumb.height) / float(thumb.width)
            db.put([thumb, img])

        height = int(float(width) * img.ratio)

        path = os.path.join(os.path.dirname(__file__), "templates", "crop.html")

        self.response.out.write(
            template.render(path, {"img": img, "width": width, "height": height, "IMAGE_APP_PATH": IMAGE_APP_PATH})
        )
开发者ID:mentat,项目名称:imageapp,代码行数:22,代码来源:views.py

示例14: get

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import get [as 别名]
    def get(self, key, size):
        img = Image.get(key)

        # Cache resized images in blobstore

        query = img.sized_images.filter("size = ", int(size))
        logging.debug("Image: query for size '%s' has %d items" % (size, query.count()))
        if query.count() == 0:
            # Store resized version
            data = images.resize(img.data, int(size))
            ri = ResizedImage()
            ri.data = db.Blob(data)
            ri.image = img
            ri.size = int(size)
            ri.put()
            self.response.out.write(data)
        else:
            # Return cached data
            self.response.out.write(query[0].data)

        self.response.headers["Content-Type"] = "image/png"
        self.response.headers["Cache-Control"] = "max-age=7200"
开发者ID:ben,项目名称:magrecipes,代码行数:24,代码来源:ImageHandler.py

示例15: get

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import get [as 别名]
 def get(self,key):
     try:
         image = Image.get(Key(key))
         self.render_template('editImage',{'image':image})
     except BadKeyError:
         self.render_template('editImage',{'error':"Image Not Found"})
开发者ID:Man-UP,项目名称:website,代码行数:8,代码来源:handlers.py


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