[mod_python] Problem with PSP and unicode

Dan Eloff dan.eloff at gmail.com
Tue Feb 14 02:10:46 EST 2006


Actually I was just about to post a question about this. The psp generated
code surrounds everything with str() before writing it, so it doesn't work
with unicode at all.

-Dan

On 2/11/06, Lukáš Zapletal <lukas.zapletal at gmail.com> wrote:
>
> Hello,
>
> I have serious problem with PSPs. The PSP cannot handle string
> variables in unicode: Here is the test:
>
> test.html:
> <!-- vim: set sw=4 ts=4 sts=4 sta et ai fenc=utf-8 : -->
> <%= test %>
>
> test.py:
> # -*- coding: utf-8 -*-
> from mod_python import apache
> from mod_python import psp
> def test(req):
>     p = psp.PSP(req, filename="test.html")
>     p.run({"test": u"STRING WITH CHARACETRS > 128"})
>
> The output of this test method:
>
> UnicodeEncodeError: 'ascii' codec can't encode character XY in
> position XY: ordinal not in range(128)
>
> What am I doing wrong? Why the PSP is trying to convert the string
> using ascii codec? I do not want this; I really need to work in
> unicode and output the result of the PSP page in unicode.
>
> Thanks in advance for help
>
> --
> Lukas Zapletal
> http://lukas.zapletalovi.com
>
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20060213/d024ac8a/attachment.html


More information about the Mod_python mailing list