[Zope] Variable name use in with statement

Dieter Maurer dieter@handshake.de
Fri, 13 Oct 2000 23:14:32 +0200 (CEST)


Burchill, Scott B. writes:
 > ....
 > I am finding myself doing the following and am sure
 > there is a simpler way to do this.
 > 
 > Any help would be greatly appreciated!  Thanks.
 > 
 > <dtml-with bid_records>
 >   <dtml-if "_.str(REQUEST.form['selection']) == 'walkon'">
 >     <dtml-with walkon>
 >       <dtml-call "REQUEST.set('cur_bidder', bidder)">
 >     </dtml-with>
 >   <dtml-elif "_.str(REQUEST.form['selection']) == 'fullhouse'">
 >     <dtml-with fullhouse>
 >       <dtml-call "REQUEST.set('cur_bidder', bidder)">
 >     </dtml-with>
 >   <dtml-else>
 >     <dtml-with snoopy>
 >       <dtml-call "REQUEST.set('cur_bidder', bidder)">
 >     </dtml-with>
 >   </dtml-if>
 > </dtml-with>
If you are sure, that only these values can occur in
"selection" (as I expect, as otherwise, it would not be a selection),
then you can use:

<dtml-call "REQUEST.set('cur_bidder',_.getitem(REQUEST.form['selection']).bidder)">


Dieter