[Zope] Simple assignment (?)

Michel Pelletier michel@digicool.com
Wed, 23 May 2001 17:36:24 -0700 (PDT)


On Wed, 23 May 2001, marc lindahl wrote:

>
> > ----- Original Message -----
> > From: "Bruce Eckel" <Bruce@EckelObjects.com>
> >> The
> >> <dtml-call currentPrice="_['sequence-item']">
> >> Doesn't work, I've tried another way or two.
>
>
> How about
>
> <dtml-call "REQUEST.set('currentPrice',_['sequence-item'])">

This is the way it should be done in DTML, but really, your code screams
to be rewritten in python.  DTML is not meant to do things like this.
Wouldn't you prefer:

for date, price in pricelist:
  if date and (DateTime() < DateTime(date)):
      currentPrice = price
return currentPrice

instead of:

<dtml-in pricelist>
  <dtml-if sequence-key>
    <dtml-if "_.DateTime() <
_.DateTime(_['sequence-key'])">
      <dtml-call currentPrice="_['sequence-item']">
    </dtml-if>
  </dtml-if>
</dtml-in>

-Michel