Args:
            cls: The :class:`OpaqueKey` subclass.
            serialized (unicode): A serialized :class:`OpaqueKey`, with namespace already removed.

        Raises:
            InvalidKeyError: Should be raised if `serialized` is not a valid serialized key
                understood by `cls`.
        """
        if serialized.count('/') != 2:
            raise InvalidKeyError(cls, serialized)

        return cls(*serialized.split('/'), deprecated=True)


CourseKey.set_deprecated_fallback(CourseLocator)


class LibraryLocator(BlockLocatorBase, CourseKey):
    """
    Locates a library. Libraries are XBlock structures with a 'library' block
    at their root.

    Libraries are treated analogously to courses for now. Once opaque keys are
    better supported, they will no longer have the 'run' property, and may no
    longer conform to CourseKey but rather some more general key type.

    Examples of valid LibraryLocator specifications:
     LibraryLocator(version_guid=ObjectId('519665f6223ebd6980884f2b'))
     LibraryLocator(org='UniX', library='PhysicsProbs')
     LibraryLocator.from_string('library-v1:UniX+PhysicsProbs')
Exemple #2
0
        been called to register a fallback class.

        Args:
            cls: The :class:`OpaqueKey` subclass.
            serialized (unicode): A serialized :class:`OpaqueKey`, with namespace already removed.

        Raises:
            InvalidKeyError: Should be raised if `serialized` is not a valid serialized key
                understood by `cls`.
        """
        if serialized.count('/') != 2:
            raise InvalidKeyError(cls, serialized)

        return cls(*serialized.split('/'), deprecated=True)

CourseKey.set_deprecated_fallback(CourseLocator)


class LibraryLocator(BlockLocatorBase, CourseKey):
    """
    Locates a library. Libraries are XBlock structures with a 'library' block
    at their root.

    Libraries are treated analogously to courses for now. Once opaque keys are
    better supported, they will no longer have the 'run' property, and may no
    longer conform to CourseKey but rather some more general key type.

    Examples of valid LibraryLocator specifications:
     LibraryLocator(version_guid=ObjectId('519665f6223ebd6980884f2b'))
     LibraryLocator(org='UniX', library='PhysicsProbs')
     LibraryLocator.from_string('library-v1:UniX+PhysicsProbs')