Changeset 5195
- Timestamp:
- 08/21/08 21:24:36 (5 months ago)
- Files:
-
- branches/1.5/turbogears/controllers.py (modified) (1 diff)
- branches/1.5/turbogears/tests/test_controllers.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.5/turbogears/controllers.py
r5194 r5195 534 534 if isinstance(v, unicode): 535 535 v = v.encode("utf8") 536 args.append( "%s=%s" % (k, urllib.quote(str(v))))536 args.append((k, str(v))) 537 537 if args: 538 result += "?" + "&".join(args) 538 query_string = urllib.urlencode(args, True) 539 if '?' in tgpath: 540 result += '&' + query_string 541 else: 542 result += '?' + query_string 539 543 return result 540 544 branches/1.5/turbogears/tests/test_controllers.py
r5185 r5195 574 574 testutil.mount(SubApp(), '/subthing/subsubthing') 575 575 576 def tearDown(self): 577 testutil.TGWebTest.tearDown(self) 578 config.update({"server.webpath": ""}) 579 576 580 def test_basic_urls(self): 577 581 self.app.get("/") … … 640 644 ) == '/?foo=bar&foo=%C3%A0' 641 645 642 def tearDown(self): 643 testutil.TGWebTest.tearDown(self) 644 config.update({"server.webpath": ""}) 645 646 def test_existing_query_string(self): 647 """url() can handle URL with existing query string""" 648 self.app.get("/") 649 test_url = url('/foo', {'first': 1}) 650 assert url(test_url, {'second': 2}) == '/foo?first=1&second=2' 646 651 647 652 def test_index_trailing_slash(self): … … 667 672 668 673 def test_url_kwargs_overwrite_tgparams(self): 669 """ Check keys in tgparams in call to url overwrite kw args"""674 """Keys in tgparams in call to url overwrite kw args""" 670 675 params = {'spamm': 'eggs'} 671 676 assert 'spamm=ham' in url('/foo', params, spamm='ham') 672 677 673 678 def test_url_doesnt_change_tgparams(self): 674 """ Test thaturl() does not change the dict passed as second arg"""679 """url() does not change the dict passed as second arg""" 675 680 params = {'spamm': 'eggs'} 676 681 assert 'foo' in url('/foo', params, spamm='ham')