dtml-let + dtml-in question
1. I'm using DTML to declare some new names in the namespace and do simple math, thus: <dtml-let subtotal_hotel_rate1="_.float(hotel_rate1) * _.int (hotel_rate1_days)"> 2. I want to display these subtotals if, say, "hotel_rate1" has a non-null value. No problem there (at least not any more thanks to Alexis and Ted!). 3. However, I then want to sum only the subtotals that get to be displayed. What's the best way of doing this? I'm stuck because to display the subtotals, I've had to close out the dtml-let tags that enabled them to be displayed in the first place. Furthermore, I can't make the calculation of the total conditional on there being just one non-null value. This would not do, for ex: <dtml-if hotel_rate1> [calculate some total] </dtml-if> because there might be a non-null value for hotel_rate2 (there are 5 hotel rates total), which has to be accounted for. I have to calculate all the subtotals and include them in the mix for the total calculation. I've thought about looping in the value of *any* namespace variable that begins with the string "subtotal_". I'd have to convert those strings to floating-point integers before doing the math. That approach sounds reasonable to me, but I don't know how construct the dtml-in syntax in this case. Any pointers/redirections/examples are greatly appreciated. Cheers, Anthony __________________________________ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com
On Mon, 2003-10-06 at 12:19, A. B. Monta wrote:
What's the best way of doing this? I'm stuck because to display the subtotals, I've had to close out the dtml-let tags that enabled them to be displayed in the first place.
Your situation would be a decent argument for using this: <dtml-call "REQUEST.set('var_name', expression)"> Where var_name *must* be quoted and expression is any valid Python expression. If you're iterating over several rates and days, you may want to load these values into a single dict or list... this will help cut down on namespace clutter. HTH, Dylan
participants (2)
-
A. B. Monta -
Dylan Reinhardt