[Zope] Sum up a property from several objects
Gitte Wange
gitte@mmmanager.org
Sun, 08 Jul 2001 23:13:16 +0200
Hello,
I have a folder contaning some objects.
These objects all have a property named CPU (it's an int).
Now I want to iterate through the folder's objects and sum up the value of
this CPU property.
I have tried with this - IMHO - really bad code:
<dtml-with my_computers>
<dtml-in "objectValues()">
<dtml-if sequence-start>
<dtml-call "REQUEST.set('new_cpu',CPU)">
<dtml-else>
<dtml-let cpu="new_cpu + CPU">
<dtml-call "REQUEST.set('new_cpu',cpu)">
</dtml-let>
</dtml-if>
</dtml-in>
</dtml-with>
But I get this error:
Error Type: KeyError
Error Value: cpu
Any other way to do this ?
(I am pretty sure there is - it's just me missing something basic here)
Regards,
Gitte Wange