Julian Edwards
Julian Edwards
I would appreciate that, thanks. I'll try and pare it down here, I am not permitted to post the code as-is, so this is not something I've run but it...
This is absolutely not using polymorphism here, it's just one example of setting properties to affect changes in validation on the nested schema, which is one of the use cases...
I think you're confusing OneOfSchema with this one? The doc I'm referring to is here https://marshmallow.readthedocs.io/en/latest/custom_fields.html#using-context where it talks about using external data to affect the serialization. My use case...
You're right in that it was a super-contrived example for the sake of brevity. But it's a general pattern I feel should be easier to do as I have quite...
I'm not sure it would help as you've still got the context data being set outside the `load()`. Ideally this needs to be encapsulated in the schema itself. I think...
> oh that's an interesting idea. would we then need `@pre_load_context`, `@post_load_context`, `@pre_dump_context`, `@post_dump_context`? Sorry only just saw this - yes, I think that would be ideal. Obviously the devil...
@Morikko Agreed - and the same problem exists with contextvars as well unless you use a different thread.
I'd love to see the suggestion in https://github.com/marshmallow-code/marshmallow/issues/2824#issuecomment-2887169436 implemented.
From what you are saying it sounds like a use case that was not intended. The reason I implemented it this way is because the parent schema is quite large...
To more accurately describe the use case of what I am doing, it's receiving a json document from an external API and one of the sub-field's schema changes depending on...