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


Python Media.update_type方法代码示例

本文整理汇总了Python中mediacore.model.Media.update_type方法的典型用法代码示例。如果您正苦于以下问题:Python Media.update_type方法的具体用法?Python Media.update_type怎么用?Python Media.update_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mediacore.model.Media的用法示例。


在下文中一共展示了Media.update_type方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _save_media_obj

# 需要导入模块: from mediacore.model import Media [as 别名]
# 或者: from mediacore.model.Media import update_type [as 别名]
    def _save_media_obj(self, name, email, title, description, tags, file, url):
        # create our media object as a status-less placeholder initially
        media_obj = Media()
        media_obj.author = Author(name, email)
        media_obj.title = title
        media_obj.slug = get_available_slug(Media, title)
        media_obj.description = description
        media_obj.notes = fetch_setting('wording_additional_notes')
        media_obj.set_tags(tags)

        # Create a media object, add it to the media_obj, and store the file permanently.
        if file is not None:
            media_file = _add_new_media_file(media_obj, file.filename, file.file)
        else:
            # FIXME: For some reason the media.type isn't ever set to video
            #        during this request. On subsequent requests, when
            #        media_obj.update_type() is called, it is set properly.
            #        This isn't too serious an issue right now because
            #        it is called the first time a moderator goes to review
            #        the new media_obj.
            media_file = MediaFile()
            url = unicode(url)
            for type, info in external_embedded_containers.iteritems():
                match = info['pattern'].match(url)
                if match:
                    media_file.type = guess_media_type(type)
                    media_file.container = type
                    media_file.embed = match.group('id')
                    media_file.display_name = type.capitalize() + ' ID: ' + media_file.embed
                    break
            else:
                # Trigger a validation error on the whole form.
                raise formencode.Invalid('Please specify a URL or upload a file below.', None, None)
            media_obj.files.append(media_file)

        # Add the final changes.
        media_obj.update_type()
        media_obj.update_status()
        DBSession.add(media_obj)
        DBSession.flush()

        create_default_thumbs_for(media_obj)

        return media_obj
开发者ID:86me,项目名称:mediacore,代码行数:46,代码来源:upload.py

示例2: _save_media_obj

# 需要导入模块: from mediacore.model import Media [as 别名]
# 或者: from mediacore.model.Media import update_type [as 别名]
    def _save_media_obj(self, name, email, title, description, tags, file):
        # cope with anonymous posters
        if name is None:
            name = 'Anonymous'

        # create our media object as a status-less placeholder initially
        media_obj = Media()
        media_obj.author = Author(name, email)
        media_obj.title = title
        media_obj.slug = get_available_slug(Media, title)
        media_obj.description = helpers.clean_xhtml(description)
        media_obj.status = 'draft,unencoded,unreviewed'
        media_obj.notes = helpers.fetch_setting('wording_additional_notes')
        media_obj.set_tags(tags)

        # Create a media object, add it to the media_obj, and store the file permanently.
        media_file = _add_new_media_file(media_obj, file.filename, file.file)

        # Add the final changes.
        media_obj.update_type()
        media_obj.update_status()
        DBSession.add(media_obj)

        return media_obj
开发者ID:SergeyLashin,项目名称:mediacore,代码行数:26,代码来源:media.py


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