Change the encoding of a single ZPT page
Hello all, Is it possible to change the encoding of a page without having to change the default-zpublisher-encoding option in zope.conf? My default encoding is iso8859-1 but we have to generate some XML files to a flash app, but flash only accept utf-8. I tried to encode the individual dynamic strings (obtained from database) in the XML with no success, since zpublisher is configured to iso8859-1 I think the xml is reencoded before it is sent. The XML file is declared with utf-8 encoding. All strings containing international characters are encoded to utf with python:reg.Field.decode('iso8859-1') in the xml file. Flash loads the xml but all international characters disappears. I'm using Zope 2.9, MySQL 4.0 with ISO8859-1 encoding. Thanks in advance, -- Luiz Fernando B. Ribeiro
--On 29. August 2006 12:28:30 -0300 Luiz Fernando Bernardes Ribeiro <luiz.fernando.ribeiro@gmail.com> wrote:
Hello all,
Is it possible to change the encoding of a page without having to change the default-zpublisher-encoding option in zope.conf?
My default encoding is iso8859-1 but we have to generate some XML files to a flash app, but flash only accept utf-8.
If you edit your ZPTs through the ZMI you might set the manage_page_charset to utf-8. If the content-type of your ZPT is set to text/xml then the ZPublisher should auto-detect the encoding from the XML preamble. The setting in zope.conf is just a fallback (at least in Zope 2.9+). -aj
Luiz Fernando Bernardes Ribeiro wrote at 2006-8-29 12:28 -0300:
Is it possible to change the encoding of a page without having to change the default-zpublisher-encoding option in zope.conf?
The "default-zpublisher-encoding" is relevant only when 1. the request returns a unicode object and 2. the "Content-Type" response header does not specify a charset. Ensure that your page sets the "Content-Type" response header correctly. -- Dieter
Dieter Maurer wrote:
The "default-zpublisher-encoding" is relevant only when
1. the request returns a unicode object
and
2. the "Content-Type" response header does not specify a charset.
Ensure that your page sets the "Content-Type" response header correctly.
Personally, I find returning a unicode and setting the default-zpublisher-encoding easier and cleaner... Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
participants (4)
-
Andreas Jung -
Chris Withers -
Dieter Maurer -
Luiz Fernando Bernardes Ribeiro