[Zope] Storing unicode in ZODB objects

Thibaud Morel l'Horset teebes at gmail.com
Mon Dec 15 15:52:35 EST 2008


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 at 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope/attachments/20081215/5dbc5e86/attachment.html 


More information about the Zope mailing list