requests_cache.serializers package¶
- class requests_cache.serializers.CattrStage(factory=None)[source]¶
Bases:
requests_cache.serializers.pipeline.Stage
Base serializer class for
CachedResponse
that does pre/post-processing withcattrs
. This does the majority of the work needed for any other serialization format, breaking down objects into python builtin types.This can be used as a stage within a
SerializerPipeline
. Requires python 3.7+.
- class requests_cache.serializers.SerializerPipeline(steps)[source]¶
Bases:
object
A sequence of steps used to serialize and deserialize response objects
- class requests_cache.serializers.Stage(obj, dumps='dumps', loads='loads')[source]¶
Bases:
object
Generic class to wrap serialization steps with consistent
dumps()
andloads()
methods
- requests_cache.serializers.init_serializer(serializer=None, **kwargs)[source]¶
Initialize a serializer from a name, class, or instance
- requests_cache.serializers.safe_pickle_serializer(secret_key=None, salt='requests-cache', **kwargs)[source]¶
Create a serializer that uses
itsdangerous
to add a signature to responses during writes, and validate that signature with a secret key during reads.
Submodules¶
requests_cache.serializers.cattrs module¶
- class requests_cache.serializers.cattrs.CattrStage(factory=None)[source]¶
Bases:
requests_cache.serializers.pipeline.Stage
Base serializer class for
CachedResponse
that does pre/post-processing withcattrs
. This does the majority of the work needed for any other serialization format, breaking down objects into python builtin types.This can be used as a stage within a
SerializerPipeline
. Requires python 3.7+.
- requests_cache.serializers.cattrs.init_converter(factory=None)[source]¶
Make a converter to structure and unstructure nested objects within a
CachedResponse
requests_cache.serializers.pipeline module¶
requests_cache.serializers.preconf module¶
The cattrs
library includes a number of pre-configured converters that perform some
additional steps required for specific serialization formats.
This module wraps those converters as serializer Stage
objects. These are then used as
a stage 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.
Requires python 3.7+.
- 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-configured stage for BSON
- requests_cache.serializers.preconf.json_preconf_stage = <requests_cache.serializers.cattrs.CattrStage object>¶
Pre-configured stage for JSON
- requests_cache.serializers.preconf.msgpack_preconf_stage = <requests_cache.serializers.cattrs.CattrStage object>¶
Pre-configured stage for msgpack
- requests_cache.serializers.preconf.orjson_preconf_stage = <requests_cache.serializers.cattrs.CattrStage object>¶
Pre-configured stage for orjson
- requests_cache.serializers.preconf.safe_pickle_serializer(secret_key=None, salt='requests-cache', **kwargs)[source]¶
Create a serializer that uses
itsdangerous
to add a signature to responses during writes, and validate that signature with a secret key during reads.
- requests_cache.serializers.preconf.toml_preconf_stage = <requests_cache.serializers.cattrs.CattrStage object>¶
Pre-configured stage for TOML
- requests_cache.serializers.preconf.ujson_preconf_stage = <requests_cache.serializers.cattrs.CattrStage object>¶
Pre-configured stage for ujson
- requests_cache.serializers.preconf.yaml_preconf_stage = <requests_cache.serializers.cattrs.CattrStage object>¶
Pre-configured stage for YAML