On Sun, Apr 12, 2009 at 3:23 PM, Jacob Holm <jh@improva.dk> wrote:
Hi Mart
>>> add_query_params('http://example.com/a/b/c?a=b', b='d', foo='/bar')'http://example.com/a/b/c?a=b&b=d&foo=%2Fbar <http://example.com/a/b/c?a=b&b=d&foo=%2Fbar>'
Duplicates are discarded:
Why discard duplicates? They are valid and have a well-defined meaning.
But if a value is given, the empty key is considered a duplicate (i.e. the
case of a&a=b is considered nonsensical):
Again, it is a valid url and this will change its meaning. Why?
'http://example.com/a/b/c?a=b&c <http://example.com/a/b/c?a=b&c>'
If you need to pass in key names that are not allowed in keyword arguments,
pass them via a dictionary in second argument:
>>> add_query_params('foo', {"+'|äüö": 'bar'})
'foo?%2B%27%7C%C3%A4%C3%BC%C3%B6=bar'
Order of original parameters is retained, although similar keys are grouped
together.
Why the grouping? Is it a side effect of your desire to discard duplicates? Changing the order like that changes the meaning of the url. A concrete case where the order of field names matters is the ":records" converter in http://pypi.python.org/pypi/zope.httpform/1.0.1 (a small independent package extracted from the form handling code in zope).
If you change it to keep duplicates and not unnecessarily mangle the field order I am +1, else I am -0.