> Date: Mon, 9 May 2005 16:21:27 -0300
> From: "Jose Henrique dos Reis" <[EMAIL PROTECTED]>
> Subject: RES: [ZPT] HTML data entry forms and ZPTs
> To: <zpt@zope.org>
> Message-ID:
>       <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset="us-ascii"
> 
> You don't need to pass explicitly person_id.  When the ZSQL method's
> arguments and form fields have the same names, the arguments are
> automatically collected from the REQUEST object.  Otherwise you have to
> call the ZSQL method with explicit arguments.

Alas, this didn't work.  I tried labeling the variable as
"REQUEST.person_id" and "person_id" in the form input field and/or in the Z
SQL method's parameters.  I also tried the Z SQL method both with a
person_id parameter (in which case I got prompted for person_id) and with no
parameter (in which case I received an error message saying the person_id is
missing).  No matter what variation I tried, it still seems that the
parameter was not getting passed from the ZPT form to the Z SQL method.
> 
> Another thing that you have to consider is that
> context.REQUEST.person_id (in your form action) contains the value of
> this variable before you submit the form, and not after.

Hmm.  Yes, very good point.  Given that fact, I guess it doesn't matter
whether I get the argument syntax right or not!

Anyway, any further suggestions would be appreciated...

- Ken
> 
> Zenrique.
> 
> >  -----Mensagem original-----
> > De:         [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]  Em nome
de
> > Ken Winter
> > Enviada em: segunda-feira, 9 de maio de 2005 15:00
> > Para:       zpt@zope.org
> > Assunto:    [ZPT] HTML data entry forms and ZPTs
> >
> > I'm trying to build a data-entry form using only ZPTs (no DTML, except
> > in the ZSQL methods that put the data into the DB).
> >
> > My little test page is at
> > http://dhat.vega.zettai.net/clients/ridhwan/dhr3/deltest.htm.  At the
> > top are the persons currently in the site's MySQL database; the
> > retrieval of them works fine.  What doesn't work is the attempt to
> > delete a person by entering an Id into the field and pressing the
> > "Delete this Person" button.
> >
> > The core ZPT code for this page is:
> >
> > <h1> People (deletion test)</h1>
> > <table tal:repeat="row here/dbobs/read_all_people" width="100%"
> > border="0" cellspacing="0" cellpadding="0"><font face="Verdana, Arial,
> > Helvetica, sans-serif">
> > <tr>
> > <td width="44%" tal:content="string:${row/person_id} -
> > ${row/first_name} ${row/middle_names} ${row/last_name}">Filler</td>
> > <td width="56%">&nbsp;</td>
> > </tr>
> > </table>
> > <p></p>
> > <form
> > action="python:here.dbobs.delete_person_py(context.REQUEST.person_id)"
> > method="post" name="delete_form">
> > <p>Id of Person To Delete:
> >    <input type="text" name="person_id:int" />
> > </p>
> > <p>
> >    <input name="do_delete" type="submit" id="do_delete" value="Delete
> > this Person" />
> > </p>
> > </form>
> > <p>The &quot;Ids&quot; are the numbers in front of each person's
> > name.</p>
> > <p><a href="deltest.htm">Refresh This Page</a></p>
> > <p tal:replace="python:here.dbobs.test1('MyParamValue')">Junk</p>
> >
> > Here is the entire body of the Python script "delete_person_py(id)"
> > that the ZPT <form> tag is trying to call and that in turn invokes the
> > ZSQL "delete_person" method:
> >
> >        container.delete_person(person_id=id)
> >
> > and here's the ZSQL method "delete_person" that it calls:
> >
> >        delete from person where person_id = <dtml-sqlvar person_id
> > type=int>
> >
> > I think I have the problem narrowed down to the call from the ZPT to
> > the Python script, which somehow fails to pass the form variable
> > "person_id" that is needed to select the person to delete.  For
> > example, I know that I can do deletes successfully by invoking the
> > Python script directly from the ZMI.  I have tried every variation on
> > the data-passing that I can think of.  I've tried calling the ZSQL
> > method directly from the ZPT.  The successful call to another script
> > at the bottom of the page rules out a bunch of other problems.  I have
> > scoured every Zope reference I can find - there are plenty of examples
> > of doing forms with DTML (e.g.
> > http://www.faqts.com/knowledge_base/view.phtml/aid/5518/fid/567), but
> > none for doing forms with ZPTs.
> >
> > There's just gotta be a "well, duh" simple solution to this, but it
> > has escaped me.
> >
> > - Thanks in advance for your help!
> > - Ken Winter << Arquivo: ATT1988512.txt >>  << Arquivo: deltest.htm >>


_______________________________________________
ZPT mailing list
ZPT@zope.org
http://mail.zope.org/mailman/listinfo/zpt

Reply via email to