[Zope] Error Checking in DTML

andrew cooke andrew at acooke.org
Mon Oct 27 10:47:07 EST 2003


the way i structure this kind of thing is to separate the process into two
steps.

1 - a page, say called "show_info" which displays the info given some
parameters and also asks for new parameter values in a form.  however, the
form doesn't send the parameters to this page but to a script (see below)

2 - a script, say called "do_show_info" which accepts the parameters,
checks them, updates the database as required, or generates error messages
or whatever, and the redirects back to the page "show_info".

so, in your case, the page show_info might include as a parameter an error
message, which the page would display.  normally this will be bank, but if
the parameters are incorrect then teh script will generate an approrpiate
message and pass it to the page.

you might find it simpler to have several pages - one for asking for
information, anotehr to display information and a third to display errors.
 again, you'd have a single script.  the user starts by entering the
information in the first page, which is sent to the script.  the script
then checks the data and either forwards to the error page or to the page
that shows the information.

this is called the model/view/controller pattern.  the model is the
database, the pages are views of the database and the controller is the
script which does the "logic".

cheers,
andew



"" said:

>   Hi,
>
>  I have a small problem. I wrote and dtml form with several input fields.
> After hitting the submit button, I pass one of the variables to an sql
> call to find. If it is a valid record, I will display my information but
> if the record is invalid, I see a blank screen.
>
>  I have goolged around and I did not find any clues to my problem. Is
> there an error type I can look for? Any help would be appreciate, thanks
>
>  Larry
>
> _______________________________________________
>
> _______________________________________________
> Zope maillist  -  Zope at zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )
>


-- 
http://www.acooke.org/andrew



More information about the Zope mailing list