Changeset 5193

Show
Ignore:
Timestamp:
08/21/08 20:49:22 (3 months ago)
Author:
carndt
Message:

Port r5191 & 5192 to 1.1 branch

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/turbogears/controllers.py

    r5145 r5193  
    540540            if isinstance(v, unicode): 
    541541                v = v.encode('utf8') 
    542             args.append('%s=%s' % (k, urllib.quote(str(v)))) 
     542            args.append((k, str(v))) 
    543543    if args: 
    544         tgpath += '?' + '&'.join(args) 
     544        query_string = urllib.urlencode(args, True) 
     545        if '?' in tgpath: 
     546            tgpath += '&' + query_string 
     547        else: 
     548            tgpath += '?' + query_string 
    545549    return tgpath 
    546550 
  • branches/1.1/turbogears/tests/test_controllers.py

    r5171 r5193  
    574574        testutil.mount(SubApp(), '/subthing/subsubthing') 
    575575 
     576    def tearDown(self): 
     577        testutil.TGWebTest.tearDown(self) 
     578        config.update({"server.webpath": ""}) 
     579 
    576580    def test_basic_urls(self): 
    577581        self.app.get("/") 
     
    636640            ) == '/?foo=bar&foo=%C3%A0' 
    637641 
    638     def tearDown(self): 
    639         testutil.TGWebTest.tearDown(self) 
    640         config.update({"server.webpath": ""}) 
    641  
     642    def test_existing_query_string(self): 
     643        """url() can handle URL with existing query string""" 
     644        self.app.get("/") 
     645        test_url = url('/foo', {'first': 1}) 
     646        assert url(test_url, {'second': 2}) == '/foo?first=1&second=2' 
    642647 
    643648    def test_index_trailing_slash(self): 
     
    663668 
    664669    def test_url_kwargs_overwrite_tgparams(self): 
    665         """Check keys in tgparams in call to url overwrite kw args""" 
     670        """Keys in tgparams in call to url() overwrite kw args""" 
    666671        params = {'spamm': 'eggs'} 
    667672        assert 'spamm=ham' in url('/foo', params, spamm='ham') 
    668673 
    669674    def test_url_doesnt_change_tgparams(self): 
    670         """Test that url() does not change the dict passed as second arg""" 
     675        """url() does not change the dict passed as second arg""" 
    671676        params = {'spamm': 'eggs'} 
    672677        assert 'foo' in url('/foo', params, spamm='ham')