[mod_python] Problem with PSP and unicode

Lukáš Zapletal lukas.zapletal at gmail.com
Sat Feb 11 04:17:47 EST 2006


I have serious problem with PSPs. The PSP cannot handle string
variables in unicode: Here is the test:

<!-- vim: set sw=4 ts=4 sts=4 sta et ai fenc=utf-8 : -->
<%= test %>

# -*- 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

More information about the Mod_python mailing list