[Zope-dev] Re: [Zope 2.10/ZPT] Fixes for encoding and webdav
issues
Andreas Jung
lists at zopyx.com
Sun Dec 17 12:40:03 EST 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
- --On 17. Dezember 2006 12:26:26 -0500 Tres Seaver <tseaver at palladion.com>
wrote:
>> A ZPT has now something as an output_encoding. When you create a ZPT
>> through the ZMI you'll be asked about the encoding (which is utf8 by
>> default). The pt_render() method now converts the internal unicode
>> representation back to the output encoding. This is basically the
>> behavior of the old ZPT implementation. In addition the __call__()
>> method sets the 'charset' property of the content-type header according
>> to the configured output encoding.
>
> That is dangerous, because a page template may be called without being
> the "main" driver for a request; the response encoding should be used,
> if already set, rather than the value set on the template.
Ok, you're right. Is there an reliable way to distinguish between
a direct call and a non-direct call?
>
>> WebDAV: the PUT factory was using the write() method to store uploaded
>> content. This method wasn't aware of the output encoding. PUT() now
>> uses pt_edit(). This implies that the uploaded content must have the same
>> encoding as the output encoding. Means: when you create a ZPT with
>> encoding UTF-8 you can't upload new content with a different encoding.
>> This is a slightly different behavior from older Zope versions and might
>> break backward compatibility. Anyone having such a usecase? One might
>> check in addition for the 'encoding' attribute inside the XML preamble
>> or for the 'charset' property inside a <meta http-equiv="content-type"
>> ..> tag for HTML documents.
>
> PUT should always extract the encoding from the upload request, and use
> it to decode the template to unicode for storage.
This works already. However there will be cases when the code can't
autodetect an encoding.
> While saving that
> encoding as the "outpout encoding" for a newly-created template is
> reasonable, modifying the "output encoding" for an existing template is
> riskier.
Newly created content-type is still an open point..look as if I have to
write a bunch of unittests for all edgecases.
- -aj
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (Darwin)
iD8DBQFFhYD0CJIWIbr9KYwRAgNHAKCPkhRE5By/ORg6HUgf/Hz3a29t2wCgxRnp
16FC8lfCNkxvPwxXHsOKMMQ=
=IxWq
-----END PGP SIGNATURE-----
More information about the Zope-Dev
mailing list