[Zope] Form records not behaving as I would expect

Steve Spicklemire steve@spvi.com
Wed, 17 Oct 2001 09:51:13 -0500


Hi Kirk,

	Try:

<dtml-call "demoSet(locationid=locationid,demoname=demoname)">

or

<dtml-call "demoSet(locationid,demoname)">

The problem is that ZSQLMethods don't inherit the DTML namespace, but 
they do look in the REQUEST object. This is why your dtml-set's were 
needed.

-steve




On Tuesday, October 16, 2001, at 03:59 PM, Kirk Strauser wrote:

> I am trying to use the 'records' directive to combine input data from a 
> form
> into records that I can insert into an SQL table using this method:
>
>
> ########################################
> Z SQL Method: demoSet
>
> Arguments:
>   locationid
>   demoname
>
> update demomap
>   set
>     locationid=<dtml-sqlvar locationid type="int">,
>     demoname=<dtml-sqlvar demoname type="string">
> ########################################
>
>
> The form I'm using is this:
>
>
> ########################################
> <dtml-var standard_html_header>
>
> <dtml-if action>
>   <br>You submitted some values!
> <dtml-in demolist>
>   <dtml-set locationid=locationid>
>   <dtml-set demoname=demoname>
>   <dtml-call demoSet>
> </dtml-in>
> </dtml-if>
>
> <form action="<dtml-var URL>" method="GET">
> <table border="<dtml-var table_border>">
> <dtml-in demoGetAll>
>   <tr>
>     <td valign="top"><dtml-var locationname>:</td>
>     <td>
>       <input type="hidden"
> name="demolist.locationid:int:records:ignore_empty" value="<dtml-var 
> locationid>">
>       <input type="text" name="demolist.demoname:string:records"
> value="<dtml-var demoname>" size="70">
>       <br><a href="<dtml-var demoname>">Test link</a>
>     </td>
>   </tr>
> </dtml-in>
>   <tr>
>     <td colspan="2" align="center">
>       <input type="submit" name="action" value="Make these changes">
>     </td>
>   </tr>
> </table>
> </form>
>
> <dtml-var standard_html_footer>
> ########################################
>
>
> The problem I'm experiencing is that the <dtml-in demolist> block in the
> DTML document above fails unless I have the seemingly-redundant dtml-set
> tags at the start of the block.  Specifically, I get a "Missing input
> variable, locationid" message and some traceback information, which I
> haven't included here but can reproduce if needed.
>
> Now, if I replace the lines
>
>   <dtml-set locationid=locationid>
>   <dtml-set demoname=demoname>
>   <dtml-call demoSet>
>
> with
>
>   <br><dtml-var locationid>
>   <br><dtml-var demoname>
>
> the the script cheerfully outputs the expected values.
>
> I'm stumped.  Why can I display those value but not insert them with an 
> SQL
> query?  I've read several HOWTOs that assert that I should only need to 
> use:
>
>   <dtml-in demolist>
>     <dtml-call demoSet>
>   </dtml-in>
>
> and be done with it.
>
> I appreciate any insight into my problem.  I'm coming from a
> C++/Java/Perl/PHP background and haven't quite gotten into the Zope way 
> of
> doing things yet, although my Zope Book should be arriving in the next 
> day
> or so.  Many advance thanks for a newbie!
> --
> Kirk Strauser
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )