[Zope] detail record editing

a.wacknitz@francotyp.com a.wacknitz@francotyp.com
Tue, 6 Jun 2000 10:14:43 +0200


> I'm just beginning my journey into Zopeland so please forgive my
> ignorance.  I'd like to be able to give users a chance to edit records
> found in a table by selecting the desired record's checkbox and then
> clicking 'Modify'.  This is similar to the Zope management screen.  I
> just don't know how to approach it.
>
> I can get Zope to generate a table and form like this from an SQL
> database.  I'm stuck after that.  The form only has one 'action' so how
> would I get it to handle the right function depending on the button that
> was pushed?  I'm no HTML expert but I've looked around quite a bit for
> an answer and I can't seem to find any info on handling multiple submit
> buttons.  Can Zope make this any easier?  (using ZClasses, maybe?)  I've
> also tried searching through the mail archives but I haven't found
> anything yet.  (There are a lot of messages to go through them one at a
> time.)

My solution for this kind of problem is to have a DTML method that delegates
to the
appropriate DTML methods. Therefore each button gets a value and a name, eg.
<input type=submit name=action value=delete>
<input type=submit name=action value=modify>

The DTML method delegating the calls looks like this:
<dtml-try>
<dtml-if "action == 'delete'">
  <dtml-call "RESPONSE.redirect('mthDelete')">
</dtml-if>
<dtml-if "action == 'modify'">
  <dtml-call "RESPONSE.redirect('mthModify')">
</dtml-if>
<dtml-except>
  <dtml-call "RESPONSE.redirect(HTTP_REFERER)">
</dtml-try>

The except part catches the cases where an error occurs such like action is
not determined.
Beware of the fact that you might want to pass further parameters in order
to determine the
selected item or so.

HTH
Andreas

Francotyp-Postalia AG & Co.
Dipl. Inform. Andreas Wacknitz
Abteilung TEE
Triftweg 21-26
D-16547 Birkenwerder
**********************************************************************
This email message has been swept by MIMEsweeper for the presence of
computer viruses.

Francotyp-Postalia AG & Co.