OpenQuizz
Une application de gestion des contenus pédagogiques
TypeRegistry Class Reference
Inheritance diagram for TypeRegistry:
Collaboration diagram for TypeRegistry:

Public Member Functions

def __init__ (self, type_codecs=None, fallback_encoder=None)
 
def __repr__ (self)
 
def __eq__ (self, other)
 

Detailed Description

Encapsulates type codecs used in encoding and / or decoding BSON, as
well as the fallback encoder. Type registries cannot be modified after
instantiation.

``TypeRegistry`` can be initialized with an iterable of type codecs, and
a callable for the fallback encoder::

  >>> from bson.codec_options import TypeRegistry
  >>> type_registry = TypeRegistry([Codec1, Codec2, Codec3, ...],
  ...                              fallback_encoder)

See :ref:`custom-type-type-registry` documentation for an example.

:Parameters:
  - `type_codecs` (optional): iterable of type codec instances. If
    ``type_codecs`` contains multiple codecs that transform a single
    python or BSON type, the transformation specified by the type codec
    occurring last prevails. A TypeError will be raised if one or more
    type codecs modify the encoding behavior of a built-in :mod:`bson`
    type.
  - `fallback_encoder` (optional): callable that accepts a single,
    unencodable python value and transforms it into a type that
    :mod:`bson` can encode. See :ref:`fallback-encoder-callable`
    documentation for an example.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  type_codecs = None,
  fallback_encoder = None 
)

Member Function Documentation

◆ __eq__()

def __eq__ (   self,
  other 
)

◆ __repr__()

def __repr__ (   self)

The documentation for this class was generated from the following file: