OpenQuizz
Une application de gestion des contenus pédagogiques
marshmallow.class_registry Namespace Reference

Functions

None register (str classname, "SchemaType" cls)
 
typing.Union[typing.List["SchemaType"], "SchemaType"] get_class (str classname, bool all=False)
 

Variables

 SchemaType
 

Detailed Description

A registry of :class:`Schema <marshmallow.Schema>` classes. This allows for string
lookup of schemas, which may be used with
class:`fields.Nested <marshmallow.fields.Nested>`.

.. warning::

This module is treated as private API.
Users should not need to use this module directly.

Function Documentation

◆ get_class()

typing.Union[typing.List["SchemaType"], "SchemaType"] marshmallow.class_registry.get_class ( str  classname,
bool   all = False 
)
Retrieve a class from the registry.

:raises: marshmallow.exceptions.RegistryError if the class cannot be found
    or if there are multiple entries for the given class name.

◆ register()

None marshmallow.class_registry.register ( str  classname,
"SchemaType"  cls 
)
Add a class to the registry of serializer classes. When a class is
registered, an entry for both its classname and its full, module-qualified
path are added to the registry.

Example: ::

    class MyClass:
        pass

    register('MyClass', MyClass)
    # Registry:
    # {
    #   'MyClass': [path.to.MyClass],
    #   'path.to.MyClass': [path.to.MyClass],
    # }

Variable Documentation

◆ SchemaType

SchemaType