<div dir="ltr">Hi Dieter,<br><br>Where is the 'manage_upload' function documented?<br><br>The problem that I had with manage_addFile seems to because I passed it a unicode object rather than a string. The error message was "<strong>'unicode' object has no attribute 'seek'</strong>" which led me to think a file-like object was needed.<br>
<br>Thanks,<br><br>Jakob<br><br><div class="gmail_quote">2008/9/2 Dieter Maurer <span dir="ltr"><<a href="mailto:dieter@handshake.de">dieter@handshake.de</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Jakob Schou Jensen wrote at 2008-9-2 09:25 +0200:<br>
<div class="Ih2E3d">>By file object I meant the "OFS.Image.File" kind. I had two problems<br>
>creating and modifying the file (at least). The first was that the<br>
>manage_addFile() function that you mention seemed to insist on a os-file<br>
>like object for the "file" parameter.<br>
<br>
</div>It is ready to accept a string or a "file" like object<br>
(usually, it gets a "ZPublisher.HTTPRequest.FileUpload" instance).<br>
<div class="Ih2E3d"><br>
>Appart from that I got a security error when I called the File.update_data()<br>
>function.<br>
<br>
</div>This is internal. The corresponding "official" method<br>
is "manage_upload".<br>
<br>
> ...<br>
<div class="Ih2E3d">>Well ... it works ... there may be a simpler way as you suggest. If you have<br>
>some sample code I would like to see it. I am using zope 2.4.something.<br>
<br>
</div>In an interactive Python session (under *nix: "bin/zopectl debug"):<br>
<br>
>>> app.manage_addProduct['OFSP'].manage_addFile('test_file', 'test_content')<br>
>>> tf=app.test_file<br>
>>> str(tf)<br>
'test_content'<br>
<br>
The example shows you, that a string is accepted as "file" value.<br>
<br>
<br>
<br>
--<br>
<font color="#888888">Dieter<br>
</font></blockquote></div><br></div>