-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
deprecate OrderedMultiDict
#2968
Comments
https://sourcegraph.com/search?q=context:global+lang:Python+werkzeug+OrderedMultiDict+-file:venv+-file:site-packages+-file:werkzeug+-repo:pallets/werkzeug+&patternType=keyword&sm=0 shows ~24 repos using I did see a couple cases where knowing the exact order that
|
@ThiefMaster Indico uses it in a few places: https://github.com/search?q=repo%3Aindico%2Findico%20orderedmultidict&type=code, thoughts? It's not clear that it's needed. |
I think IIRC there was either something in the docs on on some SO post recommending this, so there may be more people using it when they have a paypal integration in their flask app.
FWIW depending on the architecture of an application (especially when plugins are involved) it may be hard to ensure that gets called before anything else accesses the form data. The other two places where it's used are most likely leftovers from before |
PayPal IPN was one use case I saw, seems like a weird API design. The other use case I found seemed to be trying to check that a URL was canonical based not only on the query args but their exact order in the URL. I know it's not great to have to change it, but doing something like the following would probably be enough for the PayPal case, if an app can't guarantee that the data is cached first. The query args case could probably just look at class StoredImmutableMultiDict(ImmutableMultiDict):
def __init__(self, mapping):
assert isinstance(mapping, list)
self.original_items: list[tuple[str, str]] = mapping
super().__init__(mapping)
parameter_storage_class = StoredImmutableMultiDict Then you can access I did see that Werkzeug's documentation for |
FWIW I don't think paypal has any multi-value keys, so probably a normal MultiDict is enough nowadays... |
Oh yeah, that level of ordering only matters if there are actually multiple values per key, and they're submitted with keys interleaved. Seems exceedingly unlikely. |
OrderedMultiDict
is not used by Werkzeug. It has a complex implementation, and is documented to be slow.dict
maintains key insertion order in all supported versions of Python.MultiDict
already maintains the insertion order of values within a key.OrderedMultiDict
maintains the insertion order of each item, so[(a, 1), (b, 2), (a, 3)]
comes out the same instead of[(a, 1), (a, 3), (b, 2)]
. It's not clear there's a use case for this, searching sourcegraph shows some use ofOrderedMultiDict
but it's not clear if the use is actually required vs usingMultiDict
. Other libraries such as boltons also provide implementations. Mark this as deprecated and see if anything comes up.The text was updated successfully, but these errors were encountered: