Zope newbee fighting with manage_addNewFile
Hi, I've build the Zoo Example form the Zope book, but instead of guest list I want to add documents (that means a document list instead of guest list) I done a context.manage_addFile(id, title="test", file=path), where "path" is given by a dtml form. But this only creates files containing one single string indentically to "path", nothing to see from the content of the file. What's going wrong ? Permissions are set correctly, I think. Thanks ! Greetings Hans ----------------------------------- Dipl.-Ing. Hans N. Beck Waldstr. 28 75045 Walzbachtal Tel: 07203/922280 Mobil: 0177/5383233 -----------------------------------
"Hans N. Beck" wrote:
Hi,
I've build the Zoo Example form the Zope book, but instead of guest list I want to add documents (that means a document list instead of guest list) I done a
context.manage_addFile(id, title="test", file=path),
where "path" is given by a dtml form. But this only creates files containing one single string indentically to "path", nothing to see from the content of the file. What's going wrong ? Permissions are set correctly, I think.
Is your html form using a "file" type input box ? Philippe
Hi,
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Philippe Jadin Sent: Wednesday, October 17, 2001 1:18 PM To: Hans N. Beck Cc: zope@zope.org Subject: Re: [Zope] Zope newbee fighting with manage_addNewFile
"Hans N. Beck" wrote:
Hi,
I've build the Zoo Example form the Zope book, but instead
of guest list
I want to add documents (that means a document list instead of guest list) I done a
context.manage_addFile(id, title="test", file=path),
where "path" is given by a dtml form. But this only creates files containing one single string indentically to "path", nothing to see from the content of the file. What's going wrong ? Permissions are set correctly, I think.
Is your html form using a "file" type input box ?
yes, it is. Now I've tried a script from Zopelab which don't uses parameters but use REQUEST object. It seems, that there is a difference: in the REQUEST object there is somithing like a "file object". (REQUEST[key]=...)Give that to addFile as parameter works fine. My variant uses only the path as a simple string, giving it to the python script as parameter and so to addFile as parameter. In this case the created file only contains that string, the path. May be an explanation ? What exactly get I back from a form type="file" name="something" ? Greetings Hans
Philippe
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
On Wednesday 17 October 2001 09:14 am, Hans N. Beck allegedly wrote:
Hi,
[snip]
context.manage_addFile(id, title="test", file=path),
where "path" is given by a dtml form. But this only creates files containing one single string indentically to "path", nothing to see from the content of the file. What's going wrong ? Permissions are set correctly, I think.
[snip]
What's going wrong ? Permissions are set correctly, I think.
Is your html form using a "file" type input box ?
yes, it is. Now I've tried a script from Zopelab which don't uses parameters but use REQUEST object. It seems, that there is a difference: in the REQUEST object there is somithing like a "file object". (REQUEST[key]=...)Give that to addFile as parameter works fine. My variant uses only the path as a simple string, giving it to the python script as parameter and so to addFile as parameter. In this case the created file only contains that string, the path. May be an explanation ? What exactly get I back from a form type="file" name="something" ?
two things: 1. make sure your form has attributes enctype="multipart/form-data" and method="post" set on it or it will not work. 2. Do not pass the "path" to the file. Zope has no access to the filesystem of the client machine so the path is meaningless to Zope. With the enctype set, the browser will encode the file data and post it directly to Zope. Zope will then decode it into a file object and put it in the REQUEST object. Pass this file object (which has the name you gave the input field) to the manage_add... method: e.g. <form action="addFile" enctype="multipart/form-data" method="post"> <input name="file_id"><br> <input name="file_title"><br> <input name="file_data" type="file"><br> <input type="submit"> </form> Then in addFile (a Python Script): R = context.REQUEST context.manage_addFile(R.file_id, R.file_title, R.file_data) R.RESPONSE.redirect('some URL') hth, /---------------------------------------------------\ Casey Duncan, Sr. Web Developer National Legal Aid and Defender Association c.duncan@nlada.org \---------------------------------------------------/
participants (3)
-
Casey Duncan -
HNBeck@t-online.de -
Philippe Jadin