Changeset 5195

Show
Ignore:
Timestamp:
08/21/08 21:24:36 (5 months ago)
Author:
carndt
Message:

Port r5193 to 1.5 branch

Files:

Legend:

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

    r5194 r5195  
    534534            if isinstance(v, unicode): 
    535535                v = v.encode("utf8") 
    536             args.append("%s=%s" % (k, urllib.quote(str(v)))) 
     536            args.append((k, str(v))) 
    537537    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 
    539543    return result 
    540544 
  • branches/1.5/turbogears/tests/test_controllers.py

    r5185 r5195  
    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("/") 
     
    640644            ) == '/?foo=bar&foo=%C3%A0' 
    641645 
    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' 
    646651 
    647652    def test_index_trailing_slash(self): 
     
    667672 
    668673    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""" 
    670675        params = {'spamm': 'eggs'} 
    671676        assert 'spamm=ham' in url('/foo', params, spamm='ham') 
    672677 
    673678    def test_url_doesnt_change_tgparams(self): 
    674         """Test that url() does not change the dict passed as second arg""" 
     679        """url() does not change the dict passed as second arg""" 
    675680        params = {'spamm': 'eggs'} 
    676681        assert 'foo' in url('/foo', params, spamm='ham')