sorry, i missed the xplanaition. i think this'll explain... <div tal:define= penalty python:context.getPenalty(group_code=gcode,item_code=icode); penaltylen python:test(len(penalty)==0)> so not:penaltylen ensures that unit_cost is present for this row. anyway i think this worked finally : <td> <span tal:condition="not:penaltylen"> <span tal:define="unit_cost python:penalty[0].unit_cost; global sum python:sum+unit_cost" tal:content="unit_cost"/> </span> <td><b tal:content="sum"></b></td></tr> thanks deepak On 5/24/05, Deepak <dgangadhar@zeomega.com> wrote:
What r those "penaltylen" and "penalty"? and also can u tell us y u r checking "not:penaltylen"?
regards, Deepak
prabuddha ray wrote:
ok this is again freaky on my part.
my problem still remains intact .as i've told earlier, in my ZPT I needed to find a way to sum up column values if they are present and print the total at the last row.
I tried this as a Deepak pal tipped :
<span tal:condition="not:penaltylen" tal:content="python:penalty[0].unit_cost"/> <span tal:define="global sum python:sum+penalty[0].unit_cost"/> <tr><td>Total <td><b tal:content="sum"></b></td></tr>
but what happens is obvious , for reports where even one row has the unitcost missing followiing error comes up:
"tuple indx out of range"
when i changed tghe span tgs alike this :
<span tal:condition="not:penaltylen" tal:content="python:penalty[0].unit_cost"> <span tal:define="global sum python:sum+penalty[0].unit_cost"/> </span>
no error was there but the total remained 0.
No ZSQLmethod can be used to get the sum coz its pretty complex.
so plz rethink the code I'm also trying hard. hope for a reply soon
On 5/20/05, Deepak <dgangadhar@zeomega.com> wrote:
Hi Prabuddha,
check this ...
<span tal:define="global sum python:0"/> <span tal:repeat="item python:here.somesql()"> <span tal:condition="item/var" tal:define="global sum python:sum+item.var"/> </span> <span tal:content="sum"/>
thanks,
Deepak