[ZPT] Unicode error in PageTemplates/XML

Santi Camps santi at zetadb.com
Mon Dec 15 11:06:00 EST 2003


Hi all,

I've a problem using Zope Page Templates to generate XML content with
8bits-strings.  Here there is a minimalist example of what happens:

give_me_content (Python Script):
return 'maó'

test_html (PageTemplate):
<html>
  <body tal:content="here/give_me_content" />
</html>

test_xml (PageTemplate):
<?xml version="1.0" encoding="ISO-8859-15"?>
<doc xmlns:tal="http://xml.zope.org/namespaces/tal">
  <body tal:content="here/give_me_content" />
</doc>

test2_xml (PageTemplate):
<?xml version="1.0" encoding="ISO-8859-15"?>
<doc xmlns:tal="http://xml.zope.org/namespaces/tal">
  <body>maó</body>
</doc>

standard_error_message:
<error>
  <dtml-var error_tb html_quote>
</error>

test_html works fine.  No problems here.
test_xml causes an error "UnicodeError: ASCII decoding error: ordinal
not in range(128)".  My surprise is that test2_xml works fine, so it
seems to be a problem of TALES.  I've tried to encode the result using
UTF-8, but doesn't works.  It seems that only 7bit strings are allowed. 
I've also tried to debug PageTemplate.py code, but I'm not able to find
where the problem is.  Perhaps this is a problem of standard StringIO
module, but then, why it works in HTML?

Anybody knows something about this?  I'm really interested into generate
XML using TALES, but I need to be able to generate LATIN encodings.

Thanks in advance

-- 
Santi Camps
http://zetadb.sourceforge.net




More information about the ZPT mailing list