-
-
Notifications
You must be signed in to change notification settings - Fork 172
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
[Wishlist] A way to pass down custom data/context recursively to custom handlers. #452
Comments
I don't think there's builtin support for that currently, but that's a great idea! I'll see if I can get on it after I fix some of the bugs that have popped up. |
Cool! |
I don't believe the signature would get bloated, because context has to be an optional argument. Making it required would be a backwards-incompatible change, and I don't think it's a good idea to release jsonpickle 4 so soon after 3. Also, jsonpickle doesn't currently have typing information built-in because we only dropped support for CPython 2.7 with version 3.0.0, so the type signatures won't matter until I or someone else get to typing the codebase, which is likely fairly far into the future. |
Ah yes, right. |
I wish there was an easy way to pass some custom context/data down the recursive encoding to use it in my custom handlers.
In other words, I want to be able to set custom context/data that has the scope of a single call to encode/decode and can be accessed from inside the custom handler's methods.
Example (a new "context" argument is available in the custom handler's methods):
Is something like that planned? Or is there a trick I have overlooked that can be used to make such context data available in the handler?
A workaround I have come up with is to use some global state that is set before the call to
encode
and is then queried from inside the handler'sflatten
method. That however is very problematic for async code.Best wishes,
KS
The text was updated successfully, but these errors were encountered: