-
-
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
MultiDicts again #389
Comments
0.) You import 1.) The Beginning https://github.com/django/django/blob/master/django/utils/datastructures.py#L264 django_multidict = django.utils.datastructures.MultiValueDict([('username', ('jack',))])
print django_multidict['username'] # ok!
>>> 'jack' 2.) Different default behavior We already had the discussion in #287 why 3.) Dancing values WebOb handles builtin dictionaries the same way as lists of tuples, and I think a default implementation in the 4.) Here we go As said, nobody said the API of all MultiDict implementations will be the same. |
I don't think the original implementation for a multidict came from paste. The one in Werkzeug is an evolved version of the one in Django with some fixes for instantiation. The fact that you ran into the issue with string slicing in the Django version is the reason why the Werkzeug one automatically ensures that there are always internal lists. It's way too late to change the implementation of all of those I'm afraid. If you have a particular problem with the API in Werkzeug for those multidicts there are always ways to improve I assume. The design for the multidict in Werkzeug is that it should work exactly like a dict from the view of the user, not from the view of the creator of the multidict as most multidicts are created internally by the request objects and things of that nature. |
Hope we'll get one some day. It influences more thing that one can think of.
Then all libs, working with HTTP request objects must consider not only this marginal (undocumented) type, but implementation details too. What a pity.
I would say it bitten me often enough to bother. At least I've been glad to know that werkzeug's implementation is kinda like django implementation being fixed. That makes things easier. Thank you guys for answering. |
I naively thought that all python datastructures should have at least similar behavior :)
Lets look on the tests though:
Doesn't it convince that something wrong is with the whole concept of MultiDict-s?
The text was updated successfully, but these errors were encountered: