[Zope] dtml: got variable name as string, how to get to variable?

Erno Kuusela erno@iki.fi
Tue, 25 Jan 2000 05:19:02 +0200


hello,

i am writing a sql method that goes like this:

select * from packages where
<dtml-if package>
  package ~* <dtml-sqlvar package type=string> and 
</dtml-if>
<dtml-if priority>
  priority ~* <dtml-sqlvar priority type=string> and 
</dtml-if>
<dtml-if section>
  section ~* <dtml-sqlvar section type=string> and 
</dtml-if>
[...]
 1 = 1;

etc. this is a bit repetitive. so i thought i'd save a bit of typing
(well, actually i had a python snippet generate the above) and created
a property (type "tokens", looks like a list of strings) listing the
field names in the database and thought i'd do something like

<dtml-in fieldnames>
<dtml-if ???>
  <dtml-var sequence-item> ~* <dtml-sqlvar ??? type=string> and
</dtml-if>
</dtml-in>
1 = 1;

so in sequence-item i have the name of the variable i want, as a
string. the question is: what do i put in ???, or, how do i get to the
value of that variable?


also, if there is an easier, entirely different way of doing this,
suggestions are welcome :)

   -- erno

PS. please cc: me if you reply.