nameko serializer compatible with datetime and namedtuple
enhenced json serializer for nameko micro-services.
- it allow to pass datetime.date and datetime.datetime to rpc calls and event arguments. get ride of datetime.datetime not JSON serializable errors messages in nameko.
- add support for namedtuple in service transmissions. you return a namedtuple instance, you get the same namedtuple in the other side, which is retro-comatible and support either res.attr or res['attr']
Install using pip:
pip install nameko-serializers
Alternatively, you can download or clone this repo and install with :
pip install -e ..
work with nameko up to 1.12.*
- install: pip install nameko-serializers
- configure: add in your config.yaml the folowing line: serializer: nameko-serializer
datetime support (with timezone)
this Readme is currently the full documentation. it’s not a library this big…
date and datetime serializing
this serializer will handle datetime and date serializing. if a datetime is timezone naive, it will be made aware using the detected current timezone (via tzlocal.get_localzone())
all received dates will be timezone aware, but the timezone will be fixed to UTC.
this serializer allow to transmit namedtuple as dict, and will deserialize it as special namedtuple, supporting dict index
- Python 2.7, 3.6, 3.7
this serializer use the builtin ordered dict feature to unserialize namedtuple with correct attributes order. if you use python2.7 or 3.6 without cPython, you must exclusively use argument’s names and not indice.
Contributions and pull requests are welcome.
Bugs and requests
If you found a bug or if you have a request for additional feature, please use the issue tracker on GitHub.
- if you pass some objects with keys __type__, it will be converted.
- all unserialized dates will be tz aware, and tzinfo will be set to UTC. (this is a good practice to change tz at display time)
- for python < 3.7, the order in the namedtuple is not garanteed, use exclusively kwargs and attrs by names
You can use this under GPLv3.
Thanks to Nameko for this amazing framework.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size nameko_serializer-1.0.0-py2.py3-none-any.whl (6.6 kB)||File type Wheel||Python version py2.py3||Upload date||Hashes View hashes|
|Filename, size nameko-serializer-1.0.0.tar.gz (7.3 kB)||File type Source||Python version None||Upload date||Hashes View hashes|
Hashes for nameko_serializer-1.0.0-py2.py3-none-any.whl