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


Python StaticContent.get_id_from_location方法代码示例

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


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

示例1: delete_course

# 需要导入模块: from xmodule.contentstore.content import StaticContent [as 别名]
# 或者: from xmodule.contentstore.content.StaticContent import get_id_from_location [as 别名]
def delete_course(modulestore, contentstore, source_location, commit=False):
    # first check to see if the modulestore is Mongo backed
    if not isinstance(modulestore, MongoModuleStore):
        raise Exception("Expected a MongoModuleStore in the runtime. Aborting....")

    # check to see if the source course is actually there
    if not modulestore.has_item(source_location):
        raise Exception("Cannot find a course at {0}. Aborting".format(source_location))

    # first delete all of the thumbnails
    thumbs = contentstore.get_all_content_thumbnails_for_course(source_location)
    for thumb in thumbs:
        thumb_loc = Location(thumb["_id"])
        id = StaticContent.get_id_from_location(thumb_loc)
        print "Deleting {0}...".format(id)
        if commit:
            contentstore.delete(id)

    # then delete all of the assets
    assets = contentstore.get_all_content_for_course(source_location)
    for asset in assets:
        asset_loc = Location(asset["_id"])
        id = StaticContent.get_id_from_location(asset_loc)
        print "Deleting {0}...".format(id)
        if commit:
            contentstore.delete(id)

    # then delete all course modules
    modules = modulestore.get_items([source_location.tag, source_location.org, source_location.course, None, None, None])

    course_module = None
    for module in modules:
        if module.category != 'course':   # save deleting the course module for last
            print "Deleting {0}...".format(module.location)
            if commit:
                modulestore.delete_item(module.location)
        else:
            course_module = module

    if course_module:
        modulestore.delete_item(course_module.location)

    # finally delete the top-level course module itself
    print "Deleting {0}...".format(source_location)
    if commit:
        modulestore.delete_item(source_location)

    return True
开发者ID:lopezl,项目名称:edx-platform,代码行数:50,代码来源:store_utilities.py

示例2: _delete_assets

# 需要导入模块: from xmodule.contentstore.content import StaticContent [as 别名]
# 或者: from xmodule.contentstore.content.StaticContent import get_id_from_location [as 别名]
def _delete_assets(contentstore, assets, commit):
    """
    This helper method will enumerate through a list of assets and delete them
    """
    for asset in assets:
        asset_loc = Location(asset["_id"])
        id = StaticContent.get_id_from_location(asset_loc)
        logging.warning("Deleting {0}...".format(id))
        if commit:
            contentstore.delete(id)
开发者ID:Neodemia,项目名称:edx-platform,代码行数:12,代码来源:store_utilities.py

示例3: _clear_assets

# 需要导入模块: from xmodule.contentstore.content import StaticContent [as 别名]
# 或者: from xmodule.contentstore.content.StaticContent import get_id_from_location [as 别名]
def _clear_assets(location):
    store = contentstore()

    content_location = StaticContent.compute_location(
        location.org, location.course, location.name
    )

    assets, __ = store.get_all_content_for_course(content_location)
    for asset in assets:
        asset_location = Location(asset["_id"])
        id = StaticContent.get_id_from_location(asset_location)
        store.delete(id)
开发者ID:Chitrank-Dixit,项目名称:edx-platform,代码行数:14,代码来源:test_video_mongo.py

示例4: empty_asset_trashcan

# 需要导入模块: from xmodule.contentstore.content import StaticContent [as 别名]
# 或者: from xmodule.contentstore.content.StaticContent import get_id_from_location [as 别名]
def empty_asset_trashcan(course_locs):
    '''
    This method will hard delete all assets (optionally within a course_id) from the trashcan
    '''
    store = contentstore('trashcan')

    for course_loc in course_locs:
        # first delete all of the thumbnails
        thumbs = store.get_all_content_thumbnails_for_course(course_loc)
        for thumb in thumbs:
            thumb_loc = Location(thumb["_id"])
            id = StaticContent.get_id_from_location(thumb_loc)
            print "Deleting {0}...".format(id)
            store.delete(id)

        # then delete all of the assets
        assets = store.get_all_content_for_course(course_loc)
        for asset in assets:
            asset_loc = Location(asset["_id"])
            id = StaticContent.get_id_from_location(asset_loc)
            print "Deleting {0}...".format(id)
            store.delete(id)
开发者ID:6thfdwp,项目名称:edx-platform,代码行数:24,代码来源:utils.py

示例5: get_id

# 需要导入模块: from xmodule.contentstore.content import StaticContent [as 别名]
# 或者: from xmodule.contentstore.content.StaticContent import get_id_from_location [as 别名]
 def get_id(self):
     return StaticContent.get_id_from_location(self.location)
开发者ID:hughdbrown,项目名称:edx-platform,代码行数:4,代码来源:test_core_caching.py


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