[Zope] INSERT/UPDATE in SQL methods

Phillip J. Eby pje@telecommunity.com
Mon, 16 Aug 1999 17:44:08 -0500


>-----Original Message-----
>From: Bradford Hull [mailto:brad@tera.com]
>Sent: Monday, August 16, 1999 5:40 PM
>To: Hadar Pedhazur
>Subject: Re: [Zope] Giving up in frustration
>
>I'll probably be back on the bandwagon in a couple of months.  If you'll
>tell me how to hook a ZSQL method for insert/update to dtml, I'll jump back
>on now and start that chapter.  I'm not busy tonight...

Try this... let's say your INSERT or UPDATE method is called 'do_update'...
 Your DTML would look like:

<!--#call "do_update(param1=var1,param2=var2)"-->

That's basically it.  Use a #call tag and put double quotes around a
function call to the ZSQL method, passing in as keyword parameters all the
variables that it needs to do the update or insert.

I frequently then follow this with a:

<!--#call "RESPONSE.redirect('index_html')-->

to point the user's browser back to the main page of the object I've just
updated, but this is optional.  You could just make your DTML page display
a confirmation that the update took place.

Does this give you an idea how to get started?  (Note, by the way, that
sqlvar, sqltest, and sqlgroup can be used in any SQL statement that needs
variables or criteria, not just SELECT.)