diff options
| author | Jordan Cook <jordan.cook@pioneer.com> | 2022-04-15 14:48:24 -0500 |
|---|---|---|
| committer | Jordan Cook <jordan.cook@pioneer.com> | 2022-04-15 14:49:54 -0500 |
| commit | 3f6d48707e26e103dfb0029ecb33c520ed21bf1b (patch) | |
| tree | 27fea0a22208097fa4339d8815a27b50e7ab1069 /requests_cache/serializers/preconf.py | |
| parent | 8641b93fa298d9edf8ef91a03a7a2d0af6d5810e (diff) | |
| download | requests-cache-3f6d48707e26e103dfb0029ecb33c520ed21bf1b.tar.gz | |
Use BSON preconf stage and store response values under top-level keys, so created_at attribute is compatible with TTL index
Diffstat (limited to 'requests_cache/serializers/preconf.py')
| -rw-r--r-- | requests_cache/serializers/preconf.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/requests_cache/serializers/preconf.py b/requests_cache/serializers/preconf.py index 1236c44..b0ad069 100644 --- a/requests_cache/serializers/preconf.py +++ b/requests_cache/serializers/preconf.py @@ -22,10 +22,11 @@ from .cattrs import CattrStage from .pipeline import SerializerPipeline, Stage -def make_stage(preconf_module: str): +def make_stage(preconf_module: str, **kwargs): """Create a preconf serializer stage from a module name, if dependencies are installed""" try: - return CattrStage(import_module(preconf_module).make_converter) + factory = import_module(preconf_module).make_converter + return CattrStage(factory, **kwargs) except ImportError as e: return get_placeholder_class(e) @@ -33,7 +34,9 @@ def make_stage(preconf_module: str): # Pre-serialization stages base_stage = CattrStage() #: Base stage for all serializer pipelines utf8_encoder = Stage(dumps=str.encode, loads=lambda x: x.decode()) #: Encode to bytes -bson_preconf_stage = make_stage('cattr.preconf.bson') #: Pre-serialization steps for BSON +bson_preconf_stage = make_stage( + 'cattr.preconf.bson', convert_datetime=False +) #: Pre-serialization steps for BSON json_preconf_stage = make_stage('cattr.preconf.json') #: Pre-serialization steps for JSON msgpack_preconf_stage = make_stage('cattr.preconf.msgpack') #: Pre-serialization steps for msgpack orjson_preconf_stage = make_stage('cattr.preconf.orjson') #: Pre-serialization steps for orjson |
