Preconf#

The cattrs library includes a number of pre-configured converters that perform some pre-serialization steps required for specific serialization formats.

This module wraps those converters as serializer Stage objects. These are then used as stages in a SerializerPipeline, which runs after the base converter and before the format’s dumps() (or equivalent) method.

For any optional libraries that aren’t installed, the corresponding serializer will be a placeholder class that raises an ImportError at initialization time instead of at import time.

base_stage

Base stage for all serializer pipelines

bson_preconf_stage

Pre-serialization steps for BSON

bson_serializer

Complete BSON serializer; uses pymongo's bson if installed, otherwise standalone bson codec

dict_serializer

Partial serializer that unstructures responses into dicts

json_preconf_stage

Pre-serialization steps for JSON

json_serializer

Complete JSON serializer; uses ultrajson if available

make_stage

Create a preconf serializer stage from a module name, if dependencies are installed

pickle_serializer

Pickle serializer

safe_pickle_serializer

Create a serializer that uses pickle + itsdangerous to add a signature to responses on write, and validate that signature with a secret key on read.

signer_stage

Create a stage that uses itsdangerous to add a signature to responses on write, and validate that signature with a secret key on read.

ujson_preconf_stage

Pre-serialization steps for ultrajson

utf8_encoder

Encode to bytes

yaml_preconf_stage

Pre-serialization steps for YAML

yaml_serializer

Complete YAML serializer

requests_cache.serializers.preconf.base_stage = <requests_cache.serializers.cattrs.CattrStage object>#

Base stage for all serializer pipelines

requests_cache.serializers.preconf.bson_preconf_stage = <requests_cache.serializers.cattrs.CattrStage object>#

Pre-serialization steps for BSON

requests_cache.serializers.preconf.bson_serializer = <requests_cache.serializers.pipeline.SerializerPipeline object>#

Complete BSON serializer; uses pymongo’s bson if installed, otherwise standalone bson codec

requests_cache.serializers.preconf.dict_serializer = <requests_cache.serializers.pipeline.SerializerPipeline object>#

Partial serializer that unstructures responses into dicts

requests_cache.serializers.preconf.json_preconf_stage = <requests_cache.serializers.cattrs.CattrStage object>#

Pre-serialization steps for JSON

requests_cache.serializers.preconf.json_serializer = <requests_cache.serializers.pipeline.SerializerPipeline object>#

Complete JSON serializer; uses ultrajson if available

requests_cache.serializers.preconf.make_stage(preconf_module, **kwargs)[source]#

Create a preconf serializer stage from a module name, if dependencies are installed

Parameters

preconf_module (str) –

requests_cache.serializers.preconf.msgpack_preconf_stage#

alias of requests_cache._utils.get_placeholder_class.<locals>.Placeholder

requests_cache.serializers.preconf.orjson_preconf_stage#

alias of requests_cache._utils.get_placeholder_class.<locals>.Placeholder

requests_cache.serializers.preconf.pickle_serializer = <requests_cache.serializers.pipeline.SerializerPipeline object>#

Pickle serializer

requests_cache.serializers.preconf.safe_pickle_serializer(secret_key=None, salt='requests-cache', **kwargs)[source]#

Create a serializer that uses pickle + itsdangerous to add a signature to responses on write, and validate that signature with a secret key on read.

Return type

SerializerPipeline

requests_cache.serializers.preconf.signer_stage(secret_key=None, salt='requests-cache')[source]#

Create a stage that uses itsdangerous to add a signature to responses on write, and validate that signature with a secret key on read. Can be used in a SerializerPipeline in combination with any other serialization steps.

Return type

Stage

requests_cache.serializers.preconf.toml_preconf_stage#

alias of requests_cache._utils.get_placeholder_class.<locals>.Placeholder

requests_cache.serializers.preconf.ujson_preconf_stage = <requests_cache.serializers.cattrs.CattrStage object>#

Pre-serialization steps for ultrajson

requests_cache.serializers.preconf.utf8_encoder = <requests_cache.serializers.pipeline.Stage object>#

Encode to bytes

requests_cache.serializers.preconf.yaml_preconf_stage = <requests_cache.serializers.cattrs.CattrStage object>#

Pre-serialization steps for YAML

requests_cache.serializers.preconf.yaml_serializer = <requests_cache.serializers.pipeline.SerializerPipeline object>#

Complete YAML serializer