Ticket #1456: url_multi_value_fixed.patch

File url_multi_value_fixed.patch, 1.6 kB (added by imix, 1 year ago)
  • turbogears/controllers.py

    old new  
    512512        else: 
    513513            pairs = [(key, value)] 
    514514        for (k,v) in pairs: 
    515             if isinstance(value, unicode): 
    516                 value = value.encode("utf8") 
     515            if isinstance(v, unicode): 
     516                v = v.encode("utf8") 
    517517            args.append("%s=%s" % (k, urllib.quote(str(v)))) 
    518518    if args: 
    519519        result += "?" + "&".join(args) 
  • turbogears/tests/test_controllers.py

    old new  
    572572        assert url("/foo", bar=("asdf","qwer")) in \ 
    573573                ["/foo?bar=qwer&bar=asdf", "/foo?bar=asdf&bar=qwer"] 
    574574 
     575    def test_unicode(self): 
     576        "tg.url can handle unicode parameters" 
     577        assert url('/',x= 
     578            u'\N{LATIN SMALL LETTER A WITH GRAVE}'+ 
     579            u'\N{LATIN SMALL LETTER E WITH GRAVE}'+ 
     580            u'\N{LATIN SMALL LETTER I WITH GRAVE}'+ 
     581            u'\N{LATIN SMALL LETTER O WITH GRAVE}'+ 
     582            u'\N{LATIN SMALL LETTER U WITH GRAVE}') == '/?x=%C3%A0%C3%A8%C3%AC%C3%B2%C3%B9' 
     583 
     584    def test_list(self): 
     585        "tg.url can handle list parameters, with unicode too" 
     586        assert url('/',foo=['bar', u'\N{LATIN SMALL LETTER A WITH GRAVE}']) == '/?foo=bar&foo=%C3%A0' 
     587 
     588 
    575589    def tearDown(self): 
    576590        turbogears.config.update({"server.webpath" : ""}) 
    577591        turbogears.startup.startTurboGears()