routing: Transparently convert a MultiDict containing parameters.#724
routing: Transparently convert a MultiDict containing parameters.#724houseofsuns wants to merge 3 commits intopallets:masterfrom
Conversation
This allows to pass a MultiDict and get the intuitively expected result (that is multiple parameters, where multiple values are present). This allows to recreate a URL as follows: * create a URL with multiple values for a parameter * use Map.match() to extract them into a MultiDict * recreate the URL with Map.build() handing in the MultiDict The last step would fail before this commit (in that it would reproduce only one of the values for each parameter). Also this avoids the collateral damage introduced by the last attempt at allowing MultiDicts. This zaps one of the test cases in test_basic_building to reflect the changed behaviour.
|
Hm, I messed up the layout above ... |
|
You can pass in multiple query params by providing a list of values as value. Isn't that good enough? |
|
I have no strong feelings here, but I found the point that build() is then inverse to match() a big plus. For me this is more an enhancement/sugar coating so that everything works as I would intuitively expect it. Also if not this change, I will have to modify some of my code to use lists of values, so I thought I might try here first, for the benefit of the general public. :) |
Dict comprehension was added in 2.7, so we instead use a constructor.
|
I just saw the failure and fixed the syntax to be compatible to 2.6 |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This uses a more explicit version than the more elegant comprehension to get rid of the duplicate getlist call.
|
Tentative bump. What about this, it looks like I'll actually not need this anymore, but I think it would be a sensible change anyway. :) |
|
Issue history so I can keep this straight:
|
|
Continued in #1310 |
Sorry to nag once more w.r.t. the multiple values for URL building, but I think I found a way to make everybody happy. The following should allow passing in MultiDicts and receiving the desired behaviour without getting any regressions.
This should be ready to merge (as in there is test and documentation).
This allows to pass a MultiDict and get the intuitively expected result
(that is multiple parameters, where multiple values are present). This
allows to recreate a URL as follows:
The last step would fail before this commit (in that it would reproduce only
one of the values for each parameter). Also this avoids the collateral
damage introduced by the last attempt at allowing MultiDicts.
This zaps one of the test cases in test_basic_building to reflect the
changed behaviour.