本文整理汇总了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)
示例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)
示例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)))
示例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)))
示例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)
示例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)