当前位置: 首页>>代码示例>>Python>>正文


Python Media.views方法代码示例

本文整理汇总了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
开发者ID:,项目名称:,代码行数:45,代码来源:


注:本文中的mediacore.model.Media.views方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。