本文整理汇总了Python中mediacore.model.Media.views方法的典型用法代码示例。如果您正苦于以下问题:Python Media.views方法的具体用法?Python Media.views怎么用?Python Media.views使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mediacore.model.Media
的用法示例。
在下文中一共展示了Media.views方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: uploadThumb
# 需要导入模块: from mediacore.model import Media [as 别名]
# 或者: from mediacore.model.Media import views [as 别名]
def uploadThumb(self, thumb_file, podcastid, reviewed=False, **kwargs):
"""Save a thumbnail uploaded with :class:`~mediacore.forms.admin.ThumbForm`.
:param file: The uploaded file
:type file: :class:`cgi.FieldStorage` or ``None``
:rtype: JSON dict
:returns:
success
bool
message
Error message, if unsuccessful
id
The :attr:`~mediacore.model.media.Media.id` which is
important if a new media has just been created.
"""
media = Media()
media.author = Author('user', '[email protected]')
media.title = os.path.basename(thumb_file.filename)
media.slug = get_available_slug(Media, '_stub_' + media.title)
media.reviewed = reviewed
media.views = podcastid
DBSession.add(media)
DBSession.flush()
try:
# Create JPEG thumbs
create_thumbs_for(media, thumb_file.file, thumb_file.filename)
success = True
message = None
except IOError, e:
success = False
if id == 'new':
DBSession.delete(media)
if e.errno == 13:
message = _('Permission denied, cannot write file')
elif e.message == 'cannot identify image file':
message = _('Unsupport image type: %s') \
% os.path.splitext(thumb_file.filename)[1].lstrip('.')
elif e.message == 'cannot read interlaced PNG files':
message = _('Interlaced PNGs are not supported.')
else:
raise