registry
Classes:
-
Registry–A registry of storage schemes, serializers, and readers.
-
RegistryKwargs–Arguments for creating a registry.
Registry
Registry(**kwargs: Unpack[RegistryKwargs])
A registry of storage schemes, serializers, and readers.
Methods:
-
get_default_storage–Return the default storage for this registry.
-
get_serializer–Get a serializer by its name.
-
get_serializer_by_content_type–Get a serializer that can handle the given content type.
-
get_serializer_by_type–Get a serializer that can handle the given type or its parent classes.
-
get_storable–Get a storable class by its ID.
-
get_storage–Get a storage by its name.
-
get_stream_serializer–Get a stream serializer by its name.
-
get_stream_serializer_by_content_type–Get a stream serializer that can handle the given content type.
-
get_stream_serializer_by_type–Get a stream serializer that can handle the given type or its base classes.
-
get_unpacker–Get an unpacker by its name.
-
has_storable–Check if the given class is registered in this registry.
-
infer_unpacker–Get the first unpacker that can handle the given type or its parent classes.
get_serializer_by_content_type
get_serializer_by_content_type(
content_type: str,
) -> Serializer
Get a serializer that can handle the given content type.
get_serializer_by_type
get_serializer_by_type(cls: type[T]) -> Serializer[T]
Get a serializer that can handle the given type or its parent classes.
get_stream_serializer
get_stream_serializer(name: str) -> StreamSerializer
Get a stream serializer by its name.
get_stream_serializer_by_content_type
get_stream_serializer_by_content_type(
content_type: str,
) -> StreamSerializer
Get a stream serializer that can handle the given content type.
get_stream_serializer_by_type
get_stream_serializer_by_type(
cls: type[T],
) -> StreamSerializer[T]
Get a stream serializer that can handle the given type or its base classes.
has_storable
Check if the given class is registered in this registry.
RegistryKwargs
Bases: TypedDict
Arguments for creating a registry.
Attributes:
-
default_storage(bool | Storage) –Whether to set a default storage used when saving (default: False).
-
modules(Sequence[str | ModuleType] | None) –Modules to import and extract registry attributes from.
-
registries(Sequence[Registry] | None) –Other registries to merge with this one.
-
serializers(Sequence[Serializer | StreamSerializer] | None) –Serializers to register.
-
storables(Sequence[type[Storable]] | None) –Storable classes to register.
-
storages(Sequence[Storage] | None) –Storages to register.
-
unpackers(Sequence[Unpacker] | None) –Decomposers to register.
default_storage
instance-attribute
Whether to set a default storage used when saving (default: False).
modules
instance-attribute
modules: Sequence[str | ModuleType] | None
Modules to import and extract registry attributes from.
registries
instance-attribute
Other registries to merge with this one.
serializers
instance-attribute
serializers: Sequence[Serializer | StreamSerializer] | None
Serializers to register.
storables
instance-attribute
Storable classes to register.