[Zope] Return data from python

Alexis Roda alexis.roda at urv.es
Thu Sep 9 11:03:50 EDT 2004


Tuttle, Gene wrote:
> I am new to Zope and Python.
> 
> I want to be able to return the results of calculations from a python
> script. 
> The script gathers 3 bits of information from a database using 3 queries.
> I want to add up the 3 numbers and return to the calling DTML the 4 numbers.
> What is the best way to do this.

return a list or dict from python. A dict is better if you use page 
templates instead of DTML.

<dtml-let result="your_script(parameters)"
           first="result[0]"
           ...>
   <dtml-var first>
</dtml-let>

> Also as a side note...  These numbers are dollar amounts.  I have not found
> a way to format them in Python.
> Can you offer any suggestions.

Use the fmt attribute. Take a look at

http://zope.org/Documentation/Books/ZopeBook/2_6Edition/AppendixA.stx

search for fmt



HTH
-- 
                                    ////
                                   (@ @)
----------------------------oOO----(_)----OOo--------------------------
<>               Ojo por ojo y el mundo acabara ciego
/\ Alexis Roda - Universitat Rovira i Virgili - Reus, Tarragona (Spain)
-----------------------------------------------------------------------



More information about the Zope mailing list