[Zope-DB] Question about creating a form

Charlie Clark charlie at egenix.com
Tue Sep 14 06:20:01 EDT 2004


On 2004-09-08 at 16:01:45 [+0200], Laura McCord 
<Laura.McCord at doucet-austin.com> wrote:
> I have a zsql method that uses two parameters to update a table.
> Then, I have a zope page template that contains a form. Within the
> <form> tags I display the results.
> 
> For example,
> <div tal:repeat="result batch"><td width=75>
> <span tal:replace="result/UserName">UserName goes here</span></td>
> 
> Plus, I have a <select><option> menu. So the parameters needed for my
> zsql method include the value from the <select> and a result derived
> from the batch results (result/username). My question is in the <form
> action=...> do I use the zsql method as the action or is the action
> going to be a dtml method that calls the zsql method?
> 
> Preferably, I do not want to be redirected to another page. After I make
> a selection from the drop down menu I want the zsql to update my
> database and reload the page with the correct updates. The only
> interaction between the user and the form is choosing a selection from
> the <select> menu.

Hi Laura,

it is not a good idea to have a ZSQL method as the action of a form. The 
smallest problem is that you cannot specify what should happen next.

Instead you should always have a PythonScript as the action which will 
allow you to verify your form, call any methods you may need and specify 
what happens next - ie. show the original or an error page. This makes it a 
lot easier to manage your site. Jim Penny has written an excellent tutorial 
for this kind of thing which we hope to have online once I recover from 
injury... (broken shoulder and fingers). Search the archives for his 
e-mails for more information.

Good luck!

Charlie
-- 
Charlie Clark
eGenix.com

Professional Python Services directly from the Source
 >>> Python/Zope Consulting and Support ...        http://www.egenix.com/
 >>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
 >>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::


More information about the Zope-DB mailing list