[Zope] Newbie Q: creating a Z class from a web form

karthick ramanarayanan karthick@pepco.no
Fri, 9 Mar 2001 14:06:42 +0100 (CET)


Hi,
 You can try using this technique.
Works for me quite fine.

Say you have a dtml-method called index_html in the root folder
which displays the web form to the user.
Now you want to add instances from the data of the web form.

Suppose you have the standard 3 attributes of your faultItem say,
id,title and description.

Try giving this look to your index_html or any web form interface.

<dtml-var standard_html_header>
<dtml-with "manage_addProduct['faultItem']">
<form method="post" action="manage_addfaultItem">
Id:<input type="text" name="id"><br>
Title:<input type="text" name="title"><br>
Description:<input type="text" name="description"><br>
<input type="submit" name="Submit" value="Add Fault Item">
<br>
</form>
</dtml-with>
<dtml-var standard_html_footer>

I used this technique when my Product was created in Pure Python.
It worked.Should work for you too.Remove the id field in the form and call
the method to check if it works.You  set the 'id' in the manage_addfaultItem
call to that of the ZopeTime.
Bye,
A.R.Karthick(A.R.K)


> 
> I'm trying to set up a fault database using Zope, but having no
> experience with it learning is proving tricky! Here's my problem.
> 
> I've set up a ZClass called faultItem, and the constructors required to
> add a faultItem to a directory using the management interface. This
> works fine - I get a form to fill in and all the values get set up in
> the new instance.
> 
> Now I'm trying to do a user end web-form method, so users can do the
> same, but I can't work out how to get my properties from my web form
> into the new instance. I've read tutorials and how-tos but I still can't
> work it out!
> 
> Here is my faultItem method that the web form calls:
> <HTML>
> <HEAD><TITLE>Added Fault Item</TITLE></HEAD>
> <BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555">
> <dtml-call "REQUEST.set ('id', ZopeTime ().strftime ('%Y%m%d%H%M%S'))">
> <dtml-with "manage_addProduct[ 'faultItem' ]">
> <dtml-call "faultItem.createInObjectManager(REQUEST[ 'id' ], REQUEST )">
> </dtml-with>
> <h3>Thank You for your fault report!</h3>
> </body></html>
> 
> 
> What extra code would I need to transfer the values from the request
> form into the new instance with the id matching the ZopeTime?
> 
> Many thanks,
> 
> Howard Richardson,
> IT Officer,
> City University Library,
> London.
> 
> _______________________________________________
> 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 )
>