开发者

Pylons: preserve ordering in request.params?

I have a question about Pylons's request.params, which returns a MultiDict object.

Does request.params preserve the ordering of the GET parameters in a reliable way?

For example, if I were to visit http://localhost:5000/hello/index?a=1&a=2 and call request.params, could I guarantee that the MultiDict object returned would be in the following order?

>>> request.params
MultiDict([('a', '开发者_StackOverflow1'), ('a', '2')])

I'm guessing not, because Python seems to have a separate OrderedMultiDict object used for, well, ordered MultiDicts.

If not, is there any other way I can obtain the GET parameters and preserve their ordering in Pylons?


As I remember, even if you can get Pylons to preserve the ordering, you're not supposed to rely on that kind of behavior because not all user agents (browsers, bots, etc.) preserve ordering either and that's outside your control.

If it's part of the HTTP spec, it's not reliably followed... I doubt it is.

For example, suppose the user agent is a Python application which handles query parameters using dicts.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜