On 4/18/07, Max Ischenko <[EMAIL PROTECTED]> wrote:
>
> Hi
>
> Shannon -jj Behrens:
> > 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.
>
> Well, you can easily right such url_for version in your lib/
> helpers.py, can't you?
Yes, but I have multiple apps to worry about, so I was wondering if
this should maybe go in Routes or in Python's urlencode itself.
> But there may be a different solution.
>
> Why do you have utf8-encoded string in your template? Every unicode
> tutorial (including Pylons) suggests to keep string in Unicode and
> encode/decode on I/O boundaries. Therefore, you wouldn't have had this
> problem in the first place. ;)
You misunderstood me. I have unicode objects. I need to embed them
in query parameters. I can't pass a unicode object to url_for because
urlencode will croak. Hence, I was wondering who should do the
encoding. Currently, it's me, right before I call url_for. I was
wondering if maybe url_for or urlencode could do it for me. ;)
Best Regards,
-jj
--
"'Software Engineering' is something of an oxymoron. It's very
difficult to have real engineering before you have physics, and there
isn't anything even close to a physics for software." -- L. Peter
Deutsch
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---