Skip to content
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

routing: Transparently convert a MultiDict containing parameters. #724

wants to merge 3 commits into from
Changes from 1 commit
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.


Just for now


Improve performance of MultiDict conversion for routing

This uses a more explicit version than the more elegant comprehension to get
rid of the duplicate getlist call.
  • Loading branch information...
Markus Oehme
Markus Oehme committed Apr 12, 2015
commit 868c5c8a9b51c64ca60911c0c024bc786f45437c
@@ -109,7 +109,7 @@
from werkzeug._internal import _get_environ, _encode_idna
from werkzeug._compat import itervalues, iteritems, to_unicode, to_bytes, \
text_type, string_types, native_string_result, \
implements_to_string, wsgi_decoding_dance
implements_to_string, wsgi_decoding_dance, iterlists
from werkzeug.datastructures import ImmutableDict, MultiDict

@@ -1748,11 +1748,12 @@ def build(self, endpoint, values=None, method=None, force_external=False,
if values:
if isinstance(values, MultiDict):
temp = dict(
(k, (values.getlist(k)
if len(values.getlist(k)) > 1
else values[k]))
for k in values)
temp = {}
for key, list_value in iterlists(values):
if len(list_value) == 1:
temp[key] = list_value[0]
temp[key] = list_value
temp = values
values = dict((k, v) for k, v in iteritems(temp) if v is not None)
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.