File upload and setting Property
Hi, I want to upload a file and set some Propertys on this file. But when I created the file I cannot acces it to add a property with manage_addProperty I use this scheme: ## DTML-Method uploadForm ############################ <dtml-var standard_html_header> <form action="uploadAction" method="POST" enctype="multipart/form-data"> <p>Title: <input type="text" name="file_title" size=50> </p> <p>File: <input type="file" name="file_data" size=30> </p> <p>PropertyXY: <input type="text" name="file_xy" size=30> </p> </form> <dtml-var standard_html_footer> And now my Problem in the uploadAction method: ## DTML-Method uploadAction ############################ <dtml-var standard_html_header> insert one of 2 Possibilities <dtml-var standard_html_footer> Possible Insert 1: <dtml-call "manage_addFile( id='', file=file_data, title=file_title)"> <!-- Now I want to set the propertyxy but I dont know the id of the file = My problem --> Possible Insert 2: <dtml-let file_id="_.string.split(REQUEST.form['file_data'].filename,'\\')[-1]"> <dtml-call "manage_addFile( file_id, file=file_data, title=file_title)"> <!-- No I have the id of the file in the variable file_id but --> <dtml-call expr="file_id.manage_addProperty('propertyxy', file_xy, 'string')"> <!-- doesn´t work becaus there is no file 'file_id'. I tried different things like getattr(_, file_id) etc. but all this things didn't work. --> </dtml-let> I get the following Zope Error: Error Type: NameError Error Value: global name 'file_id' is not defined Thanks in advance Tilo
On Sun, 12 Aug 2001, Tilo Renz wrote:
I want to upload a file and set some Propertys on this file. But when I created the file I cannot acces it to add a property with manage_addProperty
I use this scheme:
## DTML-Method uploadForm ############################
You're using a DTML Method which cannot have properties. DTML Methods are methods of their containers--a folder, for example. If you need to set properties, you'll want to use a DTML Document. -Tim -- Tim Wilson | Visit Sibley online: | Check out: Henry Sibley HS | http://www.isd197.org | http://www.zope.com W. St. Paul, MN | | http://slashdot.org wilson@visi.com | <dtml-var pithy_quote> | http://linux.com
<dtml-call expr="file_id.manage_addProperty('propertyxy', file_xy, 'string')"> <!-- doesnŽt work becaus there is no file 'file_id'. I tried different things like getattr(_, file_id) etc. but all this things didn't work. --> </dtml-let>
I think you want something like: <dtml-call expr="_.getattr(this(), file_id).manage_addProperty('propertyxy', file_xy, 'string')"> Florent Guillaume Nuxeo
Florent Guillaume schrieb:
<dtml-call expr="file_id.manage_addProperty('propertyxy', file_xy, 'string')"> <!-- doesn´t work becaus there is no file 'file_id'. I tried different things like getattr(_, file_id) etc. but all this things didn't work. --> </dtml-let>
I think you want something like: <dtml-call expr="_.getattr(this(), file_id).manage_addProperty('propertyxy', file_xy, 'string')">
Florent Guillaume Nuxeo
Thanks - this helped Tilo Renz
Hi, --On Sonntag, 12. August 2001 13:52 +0000 Florent Guillaume <fg@nuxeo.com> wrote:
<dtml-call expr="file_id.manage_addProperty('propertyxy', file_xy, 'string')"> <!-- doesn´t work becaus there is no file 'file_id'. I tried different things like getattr(_, file_id) etc. but all this things didn't work. --> </dtml-let>
I think you want something like: <dtml-call expr="_.getattr(this(), file_id).manage_addProperty('propertyxy', file_xy, 'string')">
*shiver* ;) Would it not be better to drop DTML as a whole here? ;) Btw. <dtml-with expr="manage_addFile()"> </dtml-with> gives the context anyway. Regards Tino
participants (4)
-
Florent Guillaume -
Tilo Renz -
Timothy Wilson -
Tino Wildenhain