6.0.0 requires changes to some pre_load hooks
See original GitHub issueJust upgraded to 6.0.0. Using FlaskParser
, the input to Schema.load
is now a MultiDictProxy
wrapping a werkzeug ImmutableMultiDict
instead of a regular dictionary. This breaks a schema I have that uses a pre_load
hook to converts empty strings to None
. (I’m processing an HTML form with a bunch of optional number inputs similar to some of the solutions in marshmallow-code/marshmallow#713)
Not the biggest deal to work around but I thought I would mention it because I didn’t see it in the change log.
Also it would be convenient if MultiDictProxy
had a __repr__
to make debugging more convenient.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:10 (1 by maintainers)
Top Results From Across the Web
React Router v6 Preview
React Router contains many modules and hooks that you may not even need in your application, so depending on which pieces you import...
Read more >node.js - Webpack issue when update 4.x to 5.x - Stack Overflow
I found the error. WebPack Hot Client is not update for the last version of webpack (5.x). If you use Webpack Hot Client,...
Read more >Class: Puma::DSL — Puma-6.0.0
All the hooks run inside the Cluster::Worker#run method. ... option is used to allow your app and its gems to be properly reloaded...
Read more >ACF PRO 6.0 RC 1
ACF PRO 6.0.0 RC 1 is now available for download ! ... ACF Blocks which contain no fields now preload correctly Fix –...
Read more >Kong Gateway Changelog | Kong Docs
Fixed an issue where some items were missing from the suggestion list when ... From 3.0 onward, Kong Docker images will only contain...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, you’re spot on. I had gotten myself mixed up; sorry about that. In 5.x, parsing assembled a new dict of data, which is what got passed to the
schema.load
method (and thereby, topre_load
andpost_load
).That also explains why your hook worked in 5.x, but not in 6.0. In 5.x, you get a
dict
with your parameters. But theMultiDictProxy
you get in 6.0 wraps the raw flask/werkzeug datatype (anImmutableMultiDict
).I just looked, and werkzeug supports converting an ImmutableMultiDict to a (mutable) MultiDict. So I think for right now you could start your
pre_load
hook with a line like thisI’m thinking about whether or not / how webargs could support this more “out of the box”. For example, should we just call
copy()
on all flask multidicts on their way into the proxy object? (We’d have to check out each framework on this front too.) I don’t want to rush out a solution, but this seems like a usage we need to support – rewriting the contents of the dict in apre_load
hook.If you’re comfortable with us asking users (like yourself) to do the conversion, I’m happy with that. The performance penalty is probably negligible in the majority of cases, but I’m sure that for some combination of location/framework it would be an issue. It would be great to avoid it.
Maybe I should just close #491 . I can try to add something reasonable to the docs soon, once the upgrade doc is finished. The location you suggested looks good to me.