Cattrs#
Utilities to break down CachedResponse
objects into a dict of python builtin types
using cattrs. This does the majority of the work needed for all
serialization formats.
Base serializer class that does pre/post-processing with |
Make a converter to structure and unstructure nested objects within a |
|
Make a converter that uses Decimals instead of floats to represent timedelta objects |
- class requests_cache.serializers.cattrs.CattrStage(factory=None, decode_content=False, **kwargs)[source]#
Bases:
Stage
Base serializer class that does pre/post-processing with
cattrs
. This can be used either on its own, or as a stage within aSerializerPipeline
.- Parameters:
Notes on
decode_content
option:Response body will be decoded into a human-readable format (if possible) during serialization, and re-encoded during deserialization to reconstruct the original response.
Supported Content-Types are
application/json
andtext/*
. All other types will be saved as-is.Decoded responses are saved in a separate
_decoded_content
attribute, to ensure that_content
is always binary.This is the default behavior for Filesystem, DynamoDB, and MongoDB backends.
- dumps(value)[source]#
- Parameters:
value (
CachedResponse
) –- Return type:
- requests_cache.serializers.cattrs.init_converter(factory=None, convert_datetime=True, convert_timedelta=True)[source]#
Make a converter to structure and unstructure nested objects within a
CachedResponse