Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JsonType is not able to dump certain types #4

Open
matdrapeau opened this issue Nov 23, 2019 · 1 comment
Open

JsonType is not able to dump certain types #4

matdrapeau opened this issue Nov 23, 2019 · 1 comment

Comments

@matdrapeau
Copy link

The pickler cannot jsonify certain types like datetime.
How to change it?
Thanks

@matdrapeau
Copy link
Author

It turns out that partial_pipeline_data could receive a user in parameter and then change the kwargs['user'] to the user instance making the partial impossible to be saved (during flush) since the user is not serializable.

Here is a dirty workaround:

import flask.json
from social_sqlalchemy.storage import JSONPickler
from copy import deepcopy

def custom_dumps(value, *args, **kwargs):
    sanitized_value = deepcopy(value)
    try:
        sanitized_value['kwargs']['user'] = sanitized_value['kwargs']['user'].uid
    except:
        pass
    return flask.json.dumps(sanitized_value)


JSONPickler.dumps = custom_dumps
JSONPickler.loads = flask.json.loads

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant