Ticket #1456 (closed defect: fixed)
[PATCH] url allow key with multiple values
| Reported by: | imix | Owned by: | anonymous |
|---|---|---|---|
| Priority: | normal | Milestone: | 1.0.4 |
| Component: | TurboGears | Version: | 1.0.3 |
| Severity: | normal | Keywords: | |
| Cc: |
Description
This patch modifies the url function (in controllers.py) so that it is possible to create an url with multiple values for the same key. This is done by using a list or a tuple as value for a key.
see also: http://groups.google.com/group/turbogears/browse_thread/thread/b832b03cecd3c53e
Attachments
Change History
comment:1 Changed 5 years ago by Chris Arndt
- Status changed from new to closed
- Resolution set to fixed
comment:2 Changed 4 years ago by volvox
- Status changed from closed to reopened
- Resolution fixed deleted
This patch breaks with multiple unicode parameters. Can you add a test too, this time?
I suggest this change
else:
pairs = [(key, value)]
for (k,v) in pairs:
- if isinstance(value, unicode):
- value = value.encode("utf8")
+ if isinstance(v, unicode):
+ v = v.encode("utf8")
args.append("%s=%s" % (k, urllib.quote(str(v))))
if args:
result += "?" + "&".join(args)
I am also using this test
class UrlTest(unittest.TestCase):
def test_unicode(self):
"tg.url can handle unicode parameters"
assert tg.url('/',x=
u'\N{LATIN SMALL LETTER A WITH GRAVE}'+
u'\N{LATIN SMALL LETTER E WITH GRAVE}'+
u'\N{LATIN SMALL LETTER I WITH GRAVE}'+
u'\N{LATIN SMALL LETTER O WITH GRAVE}'+
u'\N{LATIN SMALL LETTER U WITH GRAVE}') == '/?x=%C3%A0%C3%A8%C3%AC%C3%B2%C3%B9'
def test_list(self):
"tg.url can handle list parameters, with unicode too"
assert tg.url('/',foo=['bar', u'\N{LATIN SMALL LETTER A WITH GRAVE}']) == '/?foo=bar&foo=%C3%A0'
comment:3 Changed 4 years ago by imix
- Type changed from enhancement to defect
indeed, i (obviously) missed this bug. This new patch (url_multi_value_fixed.patch) includes your fixes and the tests. Thanks
comment:5 Changed 4 years ago by Chris Arndt
- Status changed from reopened to closed
- Resolution set to fixed
Applied in r3755 and r3753/3754/r3756. Thanks!
Note: See
TracTickets for help on using
tickets.
