[Zope] Storing unicode in ZODB objects
Dieter Maurer
dieter at handshake.de
Mon Dec 15 14:56:42 EST 2008
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
More information about the Zope
mailing list