[Zope] <dtml-in item> iteration on INSERT method

Paz paz@chello.nl
Wed, 7 Mar 2001 08:53:36 +0100


Hi all,


I've used the <dtml-in item> iteration many times with dbms tables and ZSQL
methods, but always in context of an UPDATE table SET where clause. This
works because the iteration is selective to a certain value that is set from
the html page at POST or the form.

What I WANT to do now is INSERT into table using the same item construction,
when a checkbox in a multiple record form is checked. I can see in the
REQUEST.form that only certain values are present, but I cannot be selective
of this in the ZSQL method to add the records.

Here is what I have for the ZSQL method:

<dtml-in item>
insert into lpref (uid, linkid, hiearchy)
values                                          (
<dtml-sqlvar uid type=string>,
<dtml-sqlvar linkid type=int>,
0                                               )
<dtml-var sql_delimiter>
</dtml-in>

What happens is that ALL items on the form go into the DB because the item
construction does not care if the checkbox is checked or not. What I'd like
is a WHERE clause tacked to the end, but this doesnt seem to work. Dont
think and INSERT INTO table WHERE is valid.... but will have to dig the
MySQL refs.

Another thing I could do is query the checkbox value inside the iteration,
but it doesnt work because I think that Item wraps itself in a way that I
cant address it properly. Such as:

<dtml-in item>
<dtml-if "favLink">
insert into lpref (uid, linkid, hiearchy)
values                                          (
<dtml-sqlvar uid type=string>,
<dtml-sqlvar linkid type=int>,
0                                               )
</dtml-if>
<dtml-var sql_delimiter>
</dtml-in>

But I get an attribute error....

Can anyone offer me a suggestion?

Thanks as always,
Paz