[Zope] Change the encoding of a single ZPT page

Luiz Fernando Bernardes Ribeiro luiz.fernando.ribeiro at gmail.com
Wed Aug 30 13:08:24 EDT 2006


2006/8/29, Andreas Jung <lists at zopyx.com>:
>
>
>
> --On 29. August 2006 12:28:30 -0300 Luiz Fernando Bernardes Ribeiro
> <luiz.fernando.ribeiro at 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
>
>
After trying a lot of things, I found the problem is really in the
zpublisher realm, no matter what kind of encoding trick I use, even with a
python script, the output is converted to the default encoding if I use any
variable or dynamic value from the database. Changing the
'default-zpublisher-encoding' setting solved the problem but I would have to
convert hundreds of iso8859-1 html pages...

I have already recoded the XML inside a Python script where I think it will
be easier to use any magic zope trick... so I'm asking a way to avoid
changing zope.conf to produce this simgle xml file...

Python script test.xml:

request = container.REQUEST
xml = [ ]

xml.append('<?xml version="1.0" encoding="utf-8"?>')
xml.append('<lista xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:tal="http://xml.zope.org/namespaces/tal">')

xml.append('<item palavra="%s" id="%s" />' %
(container.sqlPalavras(ID=id)[0].Apelido,
id))

xml.append('</lista>')

print unicode("\n".join(xml), 'iso8859-1')
return printed

I'm using Zope 2.9.


Thanks in advance for your help and time,

-- 
Luiz Fernando B. Ribeiro
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope/attachments/20060830/4a5d3287/attachment.htm


More information about the Zope mailing list