[Zope] How do I utilize manage_edit in a stand alone form?

J Cameron Cooper jccooper@jcameroncooper.com
Wed, 04 Jun 2003 16:31:06 -0500


>
>
>I have a form (edit_file) and a method (edit) in which i am
>trying to use to edit a single fille.
>
>The examples below are not working.
>
>What am I missing.
>
>Regards, Rob a greatful newbie.
>
>============
>Form
>
><form action="edit_file" name="data" method="post">
><table cellpadding="2" cellspacing="0" width="100%"
>border="0">
>	<tr>
>		<td align="left" valign="top"></td>
>		<td align="left" valign="top"></td>
>	</tr>
>	<tr>
>		<td align="left" valign="top" colspan="2">
>		<textarea name="data:text" wrap="off" cols="90"
>rows="35"><dtml-var file1></textarea>
>		</td>
>	</tr>
>	<tr>
>		<td align="left" valign="top" colspan="2">
>		<input type="submit" name="SUBMIT" value="Save Changes">
>		</td>
>	</tr>
></table>
></form>
>
>=====================
>
>Method
>
><dtml-var standard_html_header>
><dtml-call "file1.manage_edit(file1, data, title)">
><dtml-call "RESPONSE.redirect('http://www.somewhere.com')">
><dtml-var standard_html_footer>
>  
>
#1: write your method in Python. Especially if you're doing a redirect. 
Python scripts are for logic, display templates (DTML, ZPT) are for 
rendering views.

#2: it's a lot easier to help if you explain exactly how what you're 
doing is failing. Explanation is good. Tracebacks are better.

#3: if it's actually a File you're editing, the method you call is

file1.update_data(data)

This is locatable in the Zope online help's API docs. You were using the 
API for a DTMLMethod/Document. If you actually intended this (and you 
should only put things in a DTMLDocument that you intend to render as 
DTML) you need to call it as

file1.manage_edit(data, title)

since it's a method on the object (the 'self' is gotten from the object 
the method is called on -- this is a Python idiosyncracy.)

          --jcc