本文整理匯總了Python中app.models.Image.select方法的典型用法代碼示例。如果您正苦於以下問題:Python Image.select方法的具體用法?Python Image.select怎麽用?Python Image.select使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app.models.Image
的用法示例。
在下文中一共展示了Image.select方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: page_image
# 需要導入模塊: from app.models import Image [as 別名]
# 或者: from app.models.Image import select [as 別名]
def page_image(title_id, page_num):
"""Get archive file corresponding to title ID
and member file corresponding to page number
Returns extracted image to browser"""
# Get title information
try:
volume = Volume.get(Volume.id == title_id)
except Volume.DoesNotExist:
abort(404)
# Get page information
try:
page = Image.select().join(Volume).where((Volume.id == title_id)
& (Image.page == page_num)).get()
except Image.DoesNotExist:
abort(404)
if volume.filetype == 'zip':
# TODO: Error check on archive open
z = zipfile.ZipFile(INPUT_PATH+volume.filename)
# Get page binary data
# TODO: Error checking
zf = z.read(page.filename)
z.close()
# Return extracted image to browser
return send_file(BytesIO(zf), mimetype=page.mimetype)
elif volume.filetype == 'rar':
# TODO: Error check on archive open
rar = rarfile.RarFile(INPUT_PATH+volume.filename)
# Get page binary data
# TODO: Error checking
rardata = rar.read(page.filename)
rar.close()
# Return extracted image to browser
return send_file(BytesIO(rardata), mimetype=page.mimetype)
# unrecognised archive type
else:
abort(500)
示例2: slide
# 需要導入模塊: from app.models import Image [as 別名]
# 或者: from app.models.Image import select [as 別名]
def slide(title_id):
"""Test template for Unslider display, displays Title title_id"""
# Get title information
try:
volume = Volume.get(Volume.id == title_id)
except Volume.DoesNotExist:
abort(404)
# Get list of images for this title
pages = Image.select(Image, Volume).join(Volume).where(
Volume.id == title_id).order_by(Image.page)
# Pass volume and page details to Unslider template
return render_template("slider.html", title_id=title_id, volume=volume, pages=pages)
示例3: title
# 需要導入模塊: from app.models import Image [as 別名]
# 或者: from app.models.Image import select [as 別名]
def title(title_id):
"""
Render title (grid of thumbnails).
Image 0 as blurred CSS background?
"""
# Get title information
try:
volume = Volume.get(Volume.id == title_id)
except Volume.DoesNotExist:
abort(404)
# Get list of images for this title
thumbs = Image.select(Image, Volume).join(Volume).where(Volume.id == title_id).order_by(Image.page)
# Get list of tags for this title
tags = Tag.select(Tag, TagRelation, Volume).join(TagRelation).join(Volume).where(Volume.id == title_id).order_by(Tag.name)
# pass list of thumbnails to template
return render_template("title.html", title=volume.title,
id=str(title_id), thumbs=thumbs, tags=tags)