[Zope] Adding new property to an image file
J. Cameron Cooper
jccooper at jcameroncooper.com
Mon Nov 17 20:11:22 EST 2003
Mico Siahaan wrote:
>I am making a form that would permit user to upload image file into Zope
>system. The user have to fill the information required such as: id, title,
>file to upload and short story about that image.
>
>So I make this DTMLs:
>
>addImage_html:
><dtml-var standard_html_header>
><form method="post" action="addGalery" enctype="multipart/form-data">
><p>Id : <input type="text" name="id">
><p>Title: <input type="text" name="title">
><p>Description: <input type="text" name="description">
><p>File: <input type="file" name="file" value="">
><p><input type="submit" name="submit" value="Save Image">
></form>
><dtml-var standard_html_footer>
>
>addGalery:
><dtml-var standard_html_header>
><dtml-var REQUEST>
><dtml-call "manage_addImage(REQUEST.id, REQUEST.file, REQUEST.title)">
><dtml-call "RESPONSE.redirect(URL1+'/toc')">
><dtml-var standard_html_footer>
>
>---
>
>The problem is I want to add a new property (description) to each image
>created by addGalery DTML Method. I have put this in addGalery:
>
><dtml-call
>"REQUEST.id.manage_addProperty('description',REQUEST.description,'string')">
>
>But it failed. I know that manage_addProperty method is an object method
>and REQUEST.id would not return the object I need. My question is: how to
>correct the DTML statement above?
>
REQUEST.id is a string. Obviously that won't work. You have to look up
the thing with that id. This is probably clearer as a Python script::
request = container.REQUEST
context.manage_addImage(request.id, request.file, request.title)
context[request.id].manage_addProperty('description',
request.description,'string')
return context.toc
# or
#request.RESPONSE.redirect(URL1+'/toc')
In DTML, you would use an underscore in place of 'context', which is one
of the reasons many folks discourage use of DTML--especially for logic.
--jcc
--
"My point and period will be throughly wrought,
Or well or ill, as this day's battle's fought."
More information about the Zope
mailing list