<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7226.0">
<TITLE>RES: [ZPT] HTML data entry forms and ZPTs</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->

<P><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">You don't need to pass explicitly person_id.&nbsp; When the ZSQL method's arguments and form fields have the same names, the arguments are automatically collected from the REQUEST object.&nbsp; Otherwise you have to call the ZSQL method with explicit arguments.</FONT></P>

<P><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">Another thing that you have to consider is that context.REQUEST.person_id (in your form action) contains the value of this variable<B> before</B> you submit the form, and not<B> after</B>.</FONT></P>

<P><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">Zenrique.</FONT>
</P>
<UL>
<P><FONT FACE="Courier New"><SPAN LANG="pt-br"></SPAN></FONT><SPAN LANG="pt-br">&nbsp;<FONT SIZE=1 FACE="Tahoma">-----Mensagem original-----</FONT></SPAN>

<BR><SPAN LANG="pt-br"><B><FONT SIZE=1 FACE="Tahoma">De: &nbsp;&nbsp;&nbsp;</FONT></B> <FONT SIZE=1 FACE="Tahoma">zpt-bounces@zope.org [<A HREF="mailto:zpt-bounces@zope.org">mailto:zpt-bounces@zope.org</A>]&nbsp;</FONT><B> <FONT SIZE=1 FACE="Tahoma">Em nome de</FONT></B> <FONT SIZE=1 FACE="Tahoma">Ken Winter</FONT></SPAN>

<BR><SPAN LANG="pt-br"><B><FONT SIZE=1 FACE="Tahoma">Enviada em:&nbsp;&nbsp;&nbsp;&nbsp;</FONT></B> <FONT SIZE=1 FACE="Tahoma">segunda-feira, 9 de maio de 2005 15:00</FONT></SPAN>

<BR><SPAN LANG="pt-br"><B><FONT SIZE=1 FACE="Tahoma">Para:&nbsp;&nbsp;</FONT></B> <FONT SIZE=1 FACE="Tahoma">zpt@zope.org</FONT></SPAN>

<BR><SPAN LANG="pt-br"><B><FONT SIZE=1 FACE="Tahoma">Assunto:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT></B> <FONT SIZE=1 FACE="Tahoma">[ZPT] HTML data entry forms and ZPTs</FONT></SPAN>
</P>

<P><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">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).&nbsp; </FONT></SPAN></P>

<P><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">My little test page is at <A HREF="http://dhat.vega.zettai.net/clients/ridhwan/dhr3/deltest.htm">http://dhat.vega.zettai.net/clients/ridhwan/dhr3/deltest.htm</A>.&nbsp; At the top are the persons currently in the site&#8217;s MySQL database; the retrieval of them works fine.&nbsp; What doesn't work is the attempt to delete a person by entering an Id into the field and pressing the &#8220;Delete this Person&#8221; button.&nbsp; </FONT></SPAN></P>

<P><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">The core ZPT code for this page is:</FONT></SPAN>
</P>

<P><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">&lt;h1&gt; People (deletion test)&lt;/h1&gt;</FONT></SPAN>

<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">&lt;table tal:repeat=&quot;row here/dbobs/read_all_people&quot; width=&quot;100%&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;font face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;&gt;</FONT></SPAN></P>

<P><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">&lt;tr&gt; </FONT></SPAN>

<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">&lt;td width=&quot;44%&quot; tal:content=&quot;string:${row/person_id} - ${row/first_name} ${row/middle_names} ${row/last_name}&quot;&gt;Filler&lt;/td&gt;</FONT></SPAN></P>

<P><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">&lt;td width=&quot;56%&quot;&gt;&amp;nbsp;&lt;/td&gt;</FONT></SPAN>

<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">&lt;/tr&gt;</FONT></SPAN>

<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">&lt;/table&gt;</FONT></SPAN>

<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">&lt;p&gt;&lt;/p&gt;</FONT></SPAN>

<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">&lt;form action=&quot;python:here.dbobs.delete_person_py(context.REQUEST.person_id)&quot; method=&quot;post&quot; name=&quot;delete_form&quot;&gt;</FONT></SPAN>

<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">&lt;p&gt;Id of Person To Delete: </FONT></SPAN>

<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">&nbsp;&nbsp; &lt;input type=&quot;text&quot; name=&quot;person_id:int&quot; /&gt;</FONT></SPAN>

<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">&lt;/p&gt;</FONT></SPAN>

<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">&lt;p&gt; </FONT></SPAN>

<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">&nbsp;&nbsp; &lt;input name=&quot;do_delete&quot; type=&quot;submit&quot; id=&quot;do_delete&quot; value=&quot;Delete this Person&quot; /&gt;</FONT></SPAN>

<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">&lt;/p&gt;</FONT></SPAN>

<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">&lt;/form&gt;</FONT></SPAN>

<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">&lt;p&gt;The &amp;quot;Ids&amp;quot; are the numbers in front of each person's name.&lt;/p&gt;</FONT></SPAN>

<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">&lt;p&gt;&lt;a href=&quot;deltest.htm&quot;&gt;Refresh This Page&lt;/a&gt;&lt;/p&gt;</FONT></SPAN>

<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">&lt;p tal:replace=&quot;python:here.dbobs.test1('MyParamValue')&quot;&gt;Junk&lt;/p&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></SPAN>
</P>

<P><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">Here is the entire body of the Python script &quot;delete_person_py(id)&quot; that the ZPT &lt;form&gt; tag is trying to call and that in turn invokes the ZSQL &quot;delete_person&quot; method:</FONT></SPAN></P>

<P><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; container.delete_person(person_id=id)</FONT></SPAN>
</P>

<P><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">and here's the ZSQL method &quot;delete_person&quot; that it calls:</FONT></SPAN>
</P>

<P><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; delete from person where person_id = &lt;dtml-sqlvar person_id type=int&gt;</FONT></SPAN>
</P>

<P><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">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 &quot;person_id&quot; that is needed to select the person to delete.&nbsp; For example, I know that I can do deletes successfully by invoking the Python script directly from the ZMI.&nbsp; I have tried every variation on the data-passing that I can think of.&nbsp; I&#8217;ve tried calling the ZSQL method directly from the ZPT.&nbsp; The successful call to another script at the bottom of the page rules out a bunch of other problems.&nbsp; I have scoured every Zope reference I can find - there are plenty of examples of doing forms with DTML (e.g. <A HREF="http://www.faqts.com/knowledge_base/view.phtml/aid/5518/fid/567">http://www.faqts.com/knowledge_base/view.phtml/aid/5518/fid/567</A>), but none for doing forms with ZPTs.</FONT></SPAN></P>

<P><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">There&#8217;s just gotta be a &#8220;well, duh&#8221; simple solution to this, but it has escaped me.</FONT></SPAN>
</P>

<P><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">- Thanks in advance for your help!</FONT></SPAN>

<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Courier New">- Ken Winter &lt;&lt; Arquivo: ATT1988512.txt &gt;&gt;&nbsp; &lt;&lt; Arquivo: deltest.htm &gt;&gt; </FONT></SPAN>
</P>
</UL>
</BODY>
</HTML>