Hi, I have written a method to create a folder with a page template inside. What I would like to do is provide the user with a form similar to the edit form with an upload file field in order to place the contents into the page template. I haven' t figured out how to recover the contents of the uploaded file. How do I access manage_upload, and how do I inject the contents into my page template? My method is : <dtml-call "manage_addFolder(folderid, foldertitle)"> <dtml-with "_[folderid]"> <dtml-call "manage_addProduct['PageTemplates'].manage_addPageTemplate('index_html', foldertitle, file)"> </dtml-with> In the API it talks about ZPythonScriptHTML_upload, but I don' t have a clue how to use it, am a (struggling) newbie.... Thanks for any clues or pointers as to where to find the answers, Marie Robichon Web Task Force European Synchrotron Radiation Facility BP 220 38043 Grenoble Cedex France http://www.esrf.fr Tel: (33) 04 76 88 21 86 Fax: (33) 04 76 88 24 27
You can do something like folows: add form and an input tags to your method: <form name=xy METHOD="POST" enctype="multipart/form-data" action="myscript"> <input type=text name="foldertitle"> <input type=file name="file"> </form> write a pyton script called myscript: parameters foldertitle='', file='' context.manage_addProduct['PageTemplates'].manage_addPageTemplate('index_htm l', foldertitle, file) robert ----- Original Message ----- From: "Marie Robichon" <robichon@esrf.fr> To: <zope@zope.org> Sent: Tuesday, May 14, 2002 9:43 AM Subject: [Zope] Uploading contents of a file
Hi,
I have written a method to create a folder with a page template inside. What I would like to do is provide the user with a form similar to the edit form with an upload file field in order to place the contents into the page template.
I haven' t figured out how to recover the contents of the uploaded file. How do I access manage_upload, and how do I inject the contents into my page template?
My method is :
<dtml-call "manage_addFolder(folderid, foldertitle)"> <dtml-with "_[folderid]">
<dtml-call "manage_addProduct['PageTemplates'].manage_addPageTemplate('index_html', foldertitle, file)">
</dtml-with>
In the API it talks about ZPythonScriptHTML_upload, but I don' t have a clue how to use it, am a (struggling) newbie....
Thanks for any clues or pointers as to where to find the answers,
Marie Robichon
Web Task Force European Synchrotron Radiation Facility BP 220 38043 Grenoble Cedex France
Tel: (33) 04 76 88 21 86 Fax: (33) 04 76 88 24 27
_______________________________________________ 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 )
Tip: I would highly suggest writing the method below as a python script. DTML is not good for coding logic. In python this would look like: context.manage_addFolder(folderid, foldertitle) product = context[folderid].manage_addProduct['Page Template'] product.manage_addPageTemplate('index_html', foldertitle, file) Be sure to add folderid, foldertitle and file as arguments to the script. Now as for your problem, make sure your form containing the file has the attribute enctype="multipart/form-data" hth, Casey On Tuesday 14 May 2002 03:43 am, Marie Robichon allegedly wrote:
Hi,
I have written a method to create a folder with a page template inside. What I would like to do is provide the user with a form similar to the edit form with an upload file field in order to place the contents into the page template.
I haven' t figured out how to recover the contents of the uploaded file. How do I access manage_upload, and how do I inject the contents into my page template?
My method is :
<dtml-call "manage_addFolder(folderid, foldertitle)"> <dtml-with "_[folderid]">
<dtml-call "manage_addProduct['PageTemplates'].manage_addPageTemplate('index_html', foldertitle, file)">
</dtml-with>
In the API it talks about ZPythonScriptHTML_upload, but I don' t have a clue how to use it, am a (struggling) newbie....
Thanks for any clues or pointers as to where to find the answers,
Marie Robichon
Web Task Force European Synchrotron Radiation Facility BP 220 38043 Grenoble Cedex France
Tel: (33) 04 76 88 21 86 Fax: (33) 04 76 88 24 27
_______________________________________________ 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 )
participants (3)
-
Casey Duncan -
Marie Robichon -
Robert Rottermann