Return an instance of `cls` parsed from its deprecated `serialized` form. This will be called only if :meth:`OpaqueKey.from_string` is unable to parse a key out of `serialized`, and only if `set_deprecated_fallback` has 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`. """ return cls(XBLOCK_V1, serialized) def _to_deprecated_string(self): """ Return a deprecated serialization of `self`. This will be called only if `set_deprecated_fallback` has been called to register a fallback class, and the key being serialized has the attribute `deprecated=True`. This serialization should not include the namespace prefix. """ return self.block_type BlockTypeKey.set_deprecated_fallback(BlockTypeKeyV1)
""" Return an instance of `cls` parsed from its deprecated `serialized` form. This will be called only if :meth:`OpaqueKey.from_string` is unable to parse a key out of `serialized`, and only if `set_deprecated_fallback` has 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`. """ return cls(XBLOCK_V1, serialized) def _to_deprecated_string(self): """ Return a deprecated serialization of `self`. This will be called only if `set_deprecated_fallback` has been called to register a fallback class, and the key being serialized has the attribute `deprecated=True`. This serialization should not include the namespace prefix. """ return self.block_type BlockTypeKey.set_deprecated_fallback(BlockTypeKeyV1)