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


Python FeaturedArtwork.get_by_id方法代码示例

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


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

示例1: post

# 需要导入模块: from models import FeaturedArtwork [as 别名]
# 或者: from models.FeaturedArtwork import get_by_id [as 别名]
  def post(self):
    id = long(self.request.get('id'))
    artwork_json = json.loads(self.request.get('json'))
    crop_tuple = tuple(float(x) for x in json.loads(self.request.get('crop')))
    target_artwork = FeaturedArtwork.get_by_id(id)
    if not target_artwork:
      self.response.set_status(404)
      return

    target_artwork.title = artwork_json['title']
    target_artwork.byline = artwork_json['byline']

    new_image_url, new_thumb_url = maybe_process_image(
        artwork_json['imageUri'],
        crop_tuple,
        target_artwork.publish_date.strftime('%Y%m%d') + ' '
            + artwork_json['title'] + ' '
            + artwork_json['byline'])
    if not new_thumb_url and 'thumbUri' in artwork_json:
      new_thumb_url = artwork_json['thumbUri']

    target_artwork.image_url = new_image_url
    target_artwork.thumb_url = new_thumb_url
    target_artwork.details_url = artwork_json['detailsUri']
    target_artwork.save()
    self.response.set_status(200)
开发者ID:109021017,项目名称:muzei,代码行数:28,代码来源:backroom.py

示例2: post

# 需要导入模块: from models import FeaturedArtwork [as 别名]
# 或者: from models.FeaturedArtwork import get_by_id [as 别名]
    def post(self):
        id = long(self.request.get("id"))
        artwork_json = json.loads(self.request.get("json"))
        crop_tuple = tuple(float(x) for x in json.loads(self.request.get("crop")))
        target_artwork = FeaturedArtwork.get_by_id(id)
        if not target_artwork:
            self.response.set_status(404)
            return

        target_artwork.title = artwork_json["title"]
        target_artwork.byline = artwork_json["byline"]

        new_image_url, new_thumb_url = maybe_process_image(
            artwork_json["imageUri"],
            crop_tuple,
            target_artwork.publish_date.strftime("%Y%m%d") + " " + artwork_json["title"] + " " + artwork_json["byline"],
        )
        if not new_thumb_url and "thumbUri" in artwork_json:
            new_thumb_url = artwork_json["thumbUri"]

        target_artwork.image_url = new_image_url
        target_artwork.thumb_url = new_thumb_url
        target_artwork.details_url = artwork_json["detailsUri"]
        target_artwork.save()
        self.response.set_status(200)
开发者ID:zhanghuanhome,项目名称:muzei,代码行数:27,代码来源:backroom.py

示例3: post

# 需要导入模块: from models import FeaturedArtwork [as 别名]
# 或者: from models.FeaturedArtwork import get_by_id [as 别名]
  def post(self):
    id = long(self.request.get('id'))
    artwork_json = json.loads(self.request.get('json'))
    crop_tuple = tuple(float(x) for x in json.loads(self.request.get('crop')))
    target_artwork = FeaturedArtwork.get_by_id(id)
    if not target_artwork:
      webapp2.abort(404)

    target_artwork.title = artwork_json['title']
    target_artwork.byline = artwork_json['byline']
    target_artwork.attribution = artwork_json['attribution'] if 'attribution' in artwork_json else None

    new_image_url, new_thumb_url = maybe_process_image(
        artwork_json['imageUri'],
        crop_tuple,
        target_artwork.publish_date.strftime('%Y%m%d') + ' '
            + artwork_json['title'] + ' '
            + artwork_json['byline'])
    if not new_thumb_url and 'thumbUri' in artwork_json:
      new_thumb_url = artwork_json['thumbUri']

    target_artwork.image_url = new_image_url
    target_artwork.thumb_url = new_thumb_url
    target_artwork.details_url = artwork_json['detailsUri']
    target_artwork.save()

    self.response.set_status(200)
    self.response.out.write(json.dumps(artwork_dict(target_artwork)))
开发者ID:abdelrhman,项目名称:muzei,代码行数:30,代码来源:backroom.py

示例4: post

# 需要导入模块: from models import FeaturedArtwork [as 别名]
# 或者: from models.FeaturedArtwork import get_by_id [as 别名]
    def post(self):
        id = long(self.request.get("id"))
        artwork_json = json.loads(self.request.get("json"))
        crop_tuple = tuple(float(x) for x in json.loads(self.request.get("crop")))
        target_artwork = FeaturedArtwork.get_by_id(id)
        if not target_artwork:
            webapp2.abort(404)

        target_artwork.title = artwork_json["title"]
        target_artwork.byline = artwork_json["byline"]
        target_artwork.attribution = artwork_json["attribution"] if "attribution" in artwork_json else None

        new_image_url, new_thumb_url = backroomarthelper.maybe_process_image(
            artwork_json["imageUri"],
            crop_tuple,
            target_artwork.publish_date.strftime("%Y%m%d") + " " + artwork_json["title"] + " " + artwork_json["byline"],
        )
        if not new_thumb_url and "thumbUri" in artwork_json:
            new_thumb_url = artwork_json["thumbUri"]

        target_artwork.image_url = new_image_url
        target_artwork.thumb_url = new_thumb_url
        target_artwork.details_url = artwork_json["detailsUri"]
        target_artwork.save()

        self.response.set_status(200)
        self.response.out.write(json.dumps(artwork_dict(target_artwork)))
开发者ID:romannurik,项目名称:muzei,代码行数:29,代码来源:backroom.py

示例5: post

# 需要导入模块: from models import FeaturedArtwork [as 别名]
# 或者: from models.FeaturedArtwork import get_by_id [as 别名]
  def post(self):
    id = long(self.request.get('id'))
    artwork_json = json.loads(self.request.get('json'))
    target_artwork = FeaturedArtwork.get_by_id(id)
    if not target_artwork:
      self.response.set_status(404)
      return

    target_artwork.title = artwork_json['title']
    target_artwork.byline = artwork_json['byline']
    target_artwork.image_url = artwork_json['imageUri']
    target_artwork.thumb_url = (artwork_json['thumbUri']
               if 'thumbUri' in artwork_json
               else (artwork_json['imageUri'] + '!BlogSmall.jpg'))
    target_artwork.details_url = artwork_json['detailsUri']
    target_artwork.save()
    self.response.set_status(200)
开发者ID:ALEXGUOQ,项目名称:muzei,代码行数:19,代码来源:backroom.py

示例6: post

# 需要导入模块: from models import FeaturedArtwork [as 别名]
# 或者: from models.FeaturedArtwork import get_by_id [as 别名]
  def post(self):
    id = long(self.request.get('id'))
    artwork_json = json.loads(self.request.get('json'))
    target_artwork = FeaturedArtwork.get_by_id(id)
    if not target_artwork:
      self.response.set_status(404)
      return

    target_artwork.title = artwork_json['title']
    target_artwork.byline = artwork_json['byline']

    new_image_url, new_thumb_url = maybe_process_image(
        artwork_json['imageUri'],
        artwork_json['title'] + ' ' + artwork_json['byline'])
    if not new_thumb_url and 'thumbUri' in artwork_json:
      new_thumb_url = artwork_json['thumbUri']

    target_artwork.image_url = new_image_url
    target_artwork.thumb_url = new_thumb_url
    target_artwork.details_url = artwork_json['detailsUri']
    target_artwork.save()
    self.response.set_status(200)
开发者ID:8enSmith,项目名称:muzei,代码行数:24,代码来源:backroom.py


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