本文整理汇总了Python中pyshop.models.Release.by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Release.by_id方法的具体用法?Python Release.by_id怎么用?Python Release.by_id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyshop.models.Release
的用法示例。
在下文中一共展示了Release.by_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: show_external_release_file
# 需要导入模块: from pyshop.models import Release [as 别名]
# 或者: from pyshop.models.Release import by_id [as 别名]
def show_external_release_file(root, request):
"""
Download a release from a download url from its package information.
Must be used with :func:`pyshop.helpers.download.renderer_factory`
to download the release file.
:return: download informations
:rtype: dict
"""
session = DBSession()
settings = request.registry.settings
whlify = asbool(settings.get('pyshop.mirror.wheelify', '0'))
release = Release.by_id(session, int(request.matchdict['release_id']))
filename = (release.whlify_download_url_file if whlify else
release.download_url_file)
rv = {'url': release.download_url,
'filename': filename,
'original': release.download_url_file,
'whlify': whlify
}
release.downloads += 1
release.package.downloads += 1
session.add(release.package)
session.add(release)
request.response.date = datetime.datetime.utcnow()
return rv
示例2: show_external_release_file
# 需要导入模块: from pyshop.models import Release [as 别名]
# 或者: from pyshop.models.Release import by_id [as 别名]
def show_external_release_file(root, request):
"""
Download a release from a download url from its package information.
Must be used with :func:`pyshop.helpers.download.renderer_factory`
to download the release file.
:return: download informations
:rtype: dict
"""
session = DBSession()
release = Release.by_id(session, int(request.matchdict['release_id']))
rv = {'url': release.download_url,
'filename': release.download_url_file,
}
release.downloads += 1
release.package.downloads += 1
session.add(release.package)
session.add(release)
return rv