6 messages in com.googlegroups.pylons-discussRe: url_for and encoding
FromSent OnAttachments
Shannon -jj Behrens18 Apr 2007 16:22 
Max Ischenko18 Apr 2007 21:05 
Ben Bangert19 Apr 2007 10:45 
Shannon -jj Behrens19 Apr 2007 11:26 
Shannon -jj Behrens19 Apr 2007 11:28 
Shannon -jj Behrens19 Apr 2007 11:31 
Subject:Re: url_for and encoding
From:Shannon -jj Behrens (jjin@public.gmane.org)
Date:04/19/2007 11:28:48 AM
List:com.googlegroups.pylons-discuss

On 4/19/07, Ben Bangert <ben-@public.gmane.org> wrote:

On Apr 18, 2007, at 4:23 PM, Shannon -jj Behrens wrote:

I noticed that urllib.urlencode does THE RIGHT THING (i.e. it uses %xx) if you .encode('utf-8') the parameters first. I'm writing a ton of code that looks like h.url_for(q=stuff.encode('utf-8)), hence I'm wondering if h.url_for can do the encoding for me. Basically h.url_for should encode Unicode objects before calling urllib.urlencode.

I thought one of the patches I applied to the latest Routes will automatically utf-8 encode query args? Have you tried just dropping in a utf-8 unicode string for the param?

"Dropping in a utf-8 unicode string" Hmm.

It's either a UTF-8 encoded str or a unicode object ;) If I pass it a UTF-8 encoded str, things work, but that means I have to do the encoding myself. I was wondering if the call to .encode should go in url_for or in urlencode.

Best Regards, -jj