One more thing... as far as I can tell there is still a need to set the header through a nocall if try to display your file content as part of a larger page that is generated with out of the box Page Templates or DTML methods. So the call that I pasted below should help if anyone else ever runs into this... - Thibaud On Mon, Dec 15, 2008 at 3:52 PM, Thibaud Morel l'Horset <teebes@gmail.com>wrote:
Hi Dieter,
That makes a lot of sense, thanks. Once I encode the strings in utf-8 there are no issues.
That's a great tip about setting the content_type charset correctly. The way I was handling this so far was to specify it in the header of the page that was displaying the text: <span tal:content="nocall:python:request.response.setHeader('Content-Type','text/html; charset=UTF-8')" tal:omit-tag=""></span>
But setting the content type is a lot cleaner, so I'll be doing that from now on.
Thanks!
Thibaud
Also, in case anyone googles this... by default Zope renders content with a
On Mon, Dec 15, 2008 at 2:56 PM, Dieter Maurer <dieter@handshake.de>wrote:
Andreas Jung wrote at 2008-12-14 16:00 +0100:
On 14.12.2008 15:44 Uhr, Thibaud Morel l'Horset wrote:
Hey AJ,
Thanks. Full traceback below. Regarding storing files, I meant the File Zope Object, as added by the following API call: newFolder.manage_addFile(id,title=title, content_type="text/plain", file=content).
'file' must be an open file object and not a string with the binary content.
Almost: "file" is either a file like object or an "str" but not "unicode".
@Thibaud: encode your unicode to a byte sequence ("str") using an adequate encoding (e.g. 'utf-8').
You should then also indicate the chosen charset in "content_type", e.g. "content_type='text/plain; charset=utf-8'".
-- Dieter