mirror of https://gitlab.com/tildes/tildes.git
Browse Source
Upgrade webargs to 6.1.0
Upgrade webargs to 6.1.0
This was not a fun upgrade. webargs made some major changes to its approaches in 6.0, which are mostly covered here: https://webargs.readthedocs.io/en/latest/upgrading.html To keep using it on Tildes, this commit had to make the following changes: - Write my own wrapper for use_kwargs that changes some of the default behavior. Specifically, we want the location that data is being loaded from to default to "query" (the query string) instead of webargs' default of "json". We also needed to set the "unknown" behavior on every schema to "exclude" so that the schemas would ignore any data fields they didn't need, since the default behavior is to throw an error, which happens almost everywhere because of Intercooler variables and/or multiple use_kwargs calls for different subsets of the data. - All @pre_load hooks in schemas needed to be rewritten so that they weren't modifying data in-place (copy to a new data dict first). Because webargs is now passing all data through all schemas, modifying in-place could result in an earlier schema modifying data that would then be passed in modified form to the later ones. Specifically, this caused an issue with tags on posting a new topic, where we just wanted to treat the tags as a string, but TopicSchema would convert it to a list in @pre_load. - use_kwargs on every endpoint using non-query data needed to be updated to support the new single-location approach, either replacing an existing locations= with location=, or adding location="form", since form data was no longer used by default. - The code that parsed the errors returned by webargs/Marshmallow ValidationErrors needed to update to handle the additional "level" in the dict of errors, where errors are now split out by location and then field, instead of only by field. - A few other minor updates, like always passing a schema object instead of a class, and never passing a callable (mostly just for simplicity in the wrapper).merge-requests/126/merge
Deimos
4 years ago
32 changed files with 195 additions and 142 deletions
-
2tildes/requirements-dev.txt
-
2tildes/requirements.in
-
2tildes/requirements.txt
-
6tildes/tildes/resources/comment.py
-
6tildes/tildes/resources/group.py
-
4tildes/tildes/resources/message.py
-
4tildes/tildes/resources/topic.py
-
4tildes/tildes/resources/user.py
-
18tildes/tildes/schemas/group.py
-
20tildes/tildes/schemas/listing.py
-
40tildes/tildes/schemas/topic.py
-
37tildes/tildes/schemas/user.py
-
18tildes/tildes/views/api/web/comment.py
-
5tildes/tildes/views/api/web/group.py
-
5tildes/tildes/views/api/web/markdown_preview.py
-
5tildes/tildes/views/api/web/message.py
-
15tildes/tildes/views/api/web/topic.py
-
20tildes/tildes/views/api/web/user.py
-
4tildes/tildes/views/bookmarks.py
-
30tildes/tildes/views/decorators.py
-
6tildes/tildes/views/donate.py
-
6tildes/tildes/views/exceptions.py
-
8tildes/tildes/views/group_wiki_page.py
-
4tildes/tildes/views/ignored_topics.py
-
12tildes/tildes/views/login.py
-
6tildes/tildes/views/message.py
-
2tildes/tildes/views/notifications.py
-
26tildes/tildes/views/register.py
-
5tildes/tildes/views/settings.py
-
9tildes/tildes/views/topic.py
-
2tildes/tildes/views/user.py
-
4tildes/tildes/views/votes.py
Write
Preview
Loading…
Cancel
Save
Reference in new issue