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


Python BlockUsageLocator._from_deprecated_son方法代码示例

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


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

示例1: _query_children_for_cache_children

# 需要导入模块: from opaque_keys.edx.locator import BlockUsageLocator [as 别名]
# 或者: from opaque_keys.edx.locator.BlockUsageLocator import _from_deprecated_son [as 别名]
    def _query_children_for_cache_children(self, course_key, items):
        # first get non-draft in a round-trip
        to_process_non_drafts = super(DraftModuleStore, self)._query_children_for_cache_children(course_key, items)

        to_process_dict = {}
        for non_draft in to_process_non_drafts:
            to_process_dict[BlockUsageLocator._from_deprecated_son(non_draft["_id"], course_key.run)] = non_draft

        if self.get_branch_setting() == ModuleStoreEnum.Branch.draft_preferred:
            # now query all draft content in another round-trip
            query = []
            for item in items:
                item_usage_key = UsageKey.from_string(item).map_into_course(course_key)
                if item_usage_key.block_type not in DIRECT_ONLY_CATEGORIES:
                    query.append(as_draft(item_usage_key).to_deprecated_son())
            if query:
                query = {'_id': {'$in': query}}
                to_process_drafts = list(self.collection.find(query))

                # now we have to go through all drafts and replace the non-draft
                # with the draft. This is because the semantics of the DraftStore is to
                # always return the draft - if available
                for draft in to_process_drafts:
                    draft_loc = BlockUsageLocator._from_deprecated_son(draft["_id"], course_key.run)
                    draft_as_non_draft_loc = as_published(draft_loc)

                    # does non-draft exist in the collection
                    # if so, replace it
                    if draft_as_non_draft_loc in to_process_dict:
                        to_process_dict[draft_as_non_draft_loc] = draft

        # convert the dict - which is used for look ups - back into a list
        queried_children = to_process_dict.values()

        return queried_children
开发者ID:AlexxNica,项目名称:edx-platform,代码行数:37,代码来源:draft.py

示例2: _get_raw_parent_locations

# 需要导入模块: from opaque_keys.edx.locator import BlockUsageLocator [as 别名]
# 或者: from opaque_keys.edx.locator.BlockUsageLocator import _from_deprecated_son [as 别名]
    def _get_raw_parent_locations(self, location, key_revision):
        """
        Get the parents but don't unset the revision in their locations.

        Intended for internal use but not restricted.

        Args:
            location (UsageKey): assumes the location's revision is None; so, uses revision keyword solely
            key_revision:
                MongoRevisionKey.draft - return only the draft parent
                MongoRevisionKey.published - return only the published parent
                ModuleStoreEnum.RevisionOption.all - return both draft and published parents
        """
        _verify_revision_is_published(location)

        # create a query to find all items in the course that have the given location listed as a child
        query = self._course_key_to_son(location.course_key)
        query['definition.children'] = text_type(location)

        # find all the items that satisfy the query
        parents = self.collection.find(query, {'_id': True}, sort=[SORT_REVISION_FAVOR_DRAFT])

        # return only the parent(s) that satisfy the request
        return [
            BlockUsageLocator._from_deprecated_son(parent['_id'], location.course_key.run)
            for parent in parents
            if (
                # return all versions of the parent if revision is ModuleStoreEnum.RevisionOption.all
                key_revision == ModuleStoreEnum.RevisionOption.all or
                # return this parent if it's direct-only, regardless of which revision is requested
                parent['_id']['category'] in DIRECT_ONLY_CATEGORIES or
                # return this parent only if its revision matches the requested one
                parent['_id']['revision'] == key_revision
            )
        ]
开发者ID:AlexxNica,项目名称:edx-platform,代码行数:37,代码来源:draft.py

示例3: _from_deprecated_son

# 需要导入模块: from opaque_keys.edx.locator import BlockUsageLocator [as 别名]
# 或者: from opaque_keys.edx.locator.BlockUsageLocator import _from_deprecated_son [as 别名]
 def _from_deprecated_son(cls, id_dict, run):
     """Deprecated. See BlockUsageLocator._from_deprecated_son"""
     cls._deprecation_warning()
     return BlockUsageLocator._from_deprecated_son(id_dict, run)
开发者ID:edx,项目名称:opaque-keys,代码行数:6,代码来源:locations.py


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