[Zope] File upload and setting Property

Tilo Renz tilo.renz@student.uni-ulm.de
Sun, 12 Aug 2001 13:51:32 +0200


Hi,

I want to upload a file and set some Propertys on this file. But when I c=
reated the file I cannot acces it to add a property with manage_addProper=
ty

I use this scheme:


## DTML-Method uploadForm
############################
<dtml-var standard_html_header>
<form action=3D"uploadAction" method=3D"POST" enctype=3D"multipart/form-d=
ata">
  <p>Title:      <input type=3D"text" name=3D"file_title" size=3D50> </p>
  <p>File:       <input type=3D"file" name=3D"file_data" size=3D30>  </p>
  <p>PropertyXY: <input type=3D"text" name=3D"file_xy" size=3D30>    </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=3D'', file=3Dfile_data, title=3Dfile_title=
)">
<!-- Now I want to set the propertyxy but I dont know the id of the file =
=3D My problem -->


Possible Insert 2:
<dtml-let file_id=3D"_.string.split(REQUEST.form['file_data'].filename,'\=
\')[-1]">
  <dtml-call "manage_addFile( file_id, file=3Dfile_data, title=3Dfile_tit=
le)">
  <!-- No I have the id of the file in the variable file_id but -->
  <dtml-call expr=3D"file_id.manage_addProperty('propertyxy', file_xy, 's=
tring')">
  <!-- doesn=B4t work becaus there is no file 'file_id'.=20
  I tried different things like getattr(_, file_id) etc. but all this thi=
ngs 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