MT> Have a look at the iriencode filter (only in the unicode branch, so
MT> you'll need to read docs/templates.txt from the source). This handles
MT> the last stage of encoding to ASCII.
Thanks for pointer.
MT> You cannot necessarily skip the urlencode portion, but you may be able
MT> to. The reason is that the IRI -> URI conversion algorithm does _not_
MT> encode things like '%', so it is safe to apply to something that has
MT> already been partially encoded. However, if your proto-URL string
MT> contains a '%' that should be encoded (e.g. "100%-guaranteed"), you will
MT> need to pass it through urlencode first.
MT> So {{ tagname|urlencode|iriencode }} is completely safe, although
MT> possibly redundant (and even incorrect if tagname was something that had
MT> already been URL encoded).
Well, I think here you've missed the point. Python fails *before*
iriencode - during urlencode. Check the traceback again:
> {{ tagname|urlencode }}
>
> But when the 'tagname' contains non-ascii symbols, urlencode barfs:
>
> KeyError at /
> u'\u0420'
> Request Method: GET
> Request URL: http://localhost:8088/
> Exception Type: KeyError
> Exception Value: u'\u0420'
> Exception Location: /usr/lib/python2.4/urllib.py in quote, line 1117
> Template error
MT> You might also want to read the section call "URI and IRI handling" in
MT> docs/unicode.txt because urllib.quote() is not the most bullet-proof
MT> choice when working with unicode strings. Reading your email, I just
MT> realised I have forgotten to mention the urlencode and iriencode filters
MT> in that section, but that will be fixed when I next sit down to commit
MT> bug fixes.
Yes, I've read this document (again) but
{{ tagname | urlencode | iriencode }}
won't work due to the same error.
--
Andrey V Khavryuchenko
http://www.kds.com.ua
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" 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/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---