[Zope] Beginner question: user defined variables

Michael Guerrero mguerrero@tachyon.net
Fri, 2 Aug 2002 07:47:36 -0700


Hello,

This my first zope project.

I am trying to declare a variable called 'tot' for a total field.  =
Within a dtml-in I would like to add a value to this variable.  Then =
display the value of 'tot' after the dtml-in finishes.  I have tried the =
following ( I have placed my comments at the end of each line):

<table>
<dtml-in sql_billtest>
  <dtml-call "REQUEST.set('tot','tot' + charge_amt)">  -- here is where =
I try to declare/add to the variable 'tot'
  <tr>
      <td><dtml-var invoice_num></td>     =20
      <td><dtml-var item_type></td>     =20
      <td><dtml-var charge_amt fmt=3D"%0.2f"></td>      -- for each row =
I want to add this field to 'tot'
      <td><dtml-var tap_num></td>     =20
      <td><dtml-var subscriber_name></td>
  </tr>
</dtml-in>
  <tr>
      <td><dtml-var tot></td>     -- now I want to display the value of =
'tot'
  </tr>
</table>

When I try this I get 'cannot add type "float" to string'.  Is there a =
way to declare 'tot' as a float?

Is this the correct way to do this?   I have the 'Zope Bible' but it =
doesn't have any good examples.=20

One way a was able to get the total was to put another dtml-in after the =
first and user the 'total' statistics variable. =20
<dtml-in sql_billtest size=3D"1">
  <tr>
      <td><dtml-var total-charge_amt fmt=3D"%0.2f"></td>    =20
  </tr>
</dtml-in>

I do not prefer this way.  Since 'sql_billtest' is a database query I do =
not want to query the database twice (once for the detail and once to =
get the total).


Thanks for your help.

Mike