custom serializer

53 views
Skip to first unread message

rejo

unread,
Feb 27, 2018, 5:57:50 AM2/27/18
to nameko-dev
Hi, 

I'm new to nameko and making some tests.

I now want to setup a custom serializer so I read different posts on the subject and tried to register my serializer to kombu with

register('my_json', to_json, from_json, 'application/my_json')

My service returns a dict(v='string', on=datetime.utcnow()) 
and my serializer is able to serialize datetime 

But when I call my service I get an error 
nameko.exceptions.RemoteError: UnserializableValueError Unserializable value: `{'v': 'string', 'on': datetime.datetime(2018, 2, 27, 10, 50, 52, 648749)}`


So my question : Is it the right solution ? What did I forgot ?

Tia.

ad...@kbni.net

unread,
Mar 2, 2018, 12:07:20 AM3/2/18
to nameko-dev
I think we would have to see what to_json does exactly to know what's going wrong with your serialiser!

Here is what my serialiser looks like (shamelessly stolen from one of the more helpful chaps in this very group) -- https://gist.github.com/kbni/1775f5605de8c517c10e8cbbc12660c4 -- you'd want to remove the ServiceResult stuff if you give this a try though.

You may have figured out already, but nameko shell also requires the serialiser to be registered.
Reply all
Reply to author
Forward
0 new messages