本文整理汇总了Python中models.Image.blob方法的典型用法代码示例。如果您正苦于以下问题:Python Image.blob方法的具体用法?Python Image.blob怎么用?Python Image.blob使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Image
的用法示例。
在下文中一共展示了Image.blob方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import blob [as 别名]
def post(self):
item = None
vals = {}
# get all the incoming values
title = self.request.get('title').strip()
blob_key = None
caption = self.request.get('caption').strip()
credit_who = self.request.get('credit_who').strip()
credit_link = self.request.get('credit_link').strip() if self.request.get('credit_link') else None
label_raw = self.request.get('label_raw').strip()
# get the file information
uploaded_files = self.get_uploads('image')
if len(uploaded_files) == 1:
blob_info = uploaded_files[0]
blob_key = blob_info.key()
if self.request.get('key'):
item = Image.get( self.request.get('key') )
item.title = title
item.caption = caption
item.credit_who = credit_who
item.credit_link = credit_link
item.label_raw = label_raw
else:
item = Image(
title = title,
caption = caption,
credit_who = credit_who,
credit_link = credit_link,
label_raw = label_raw,
)
if blob_key:
item.blob = blob_key
# update and save this image
item.set_derivatives()
item.put()
self.redirect('.')