[Plone-IT] tal somma

Silvio silviot a gmail.com
Mar 25 Gen 2011 09:57:16 UTC


2011/1/25 Giuseppe Arvati <giuseppe.arvati a poste.it>

> sto provando le modifiche suggerite ma mi da ancora errore
>
> <span tal:define="global totale python:0"/>
>
>   <table class="grid listing">
>     <tr>
>        <th>Media</th>
>     </tr>
>    <tr tal:repeat="my_row here/getSMT_py">
>        <td><span tal:content="my_row/MEDIA">-0:30</span></td>
>        <span tal:define="totale python:(totale + my_row.MEDIA)"/>
>     </tr>
>
>   <span tal:content="totale">000</span>
>  </table>
>
> errore
>
>    * Module Products.PageTemplates.ZRPythonExpr, line 49, in __call__
>      __traceback_info__: (totale + my_row.MEDIA)
>    * Module PythonExpr, line 1, in <expression>
>
> AttributeError: 'dict' object has no attribute 'MEDIA'

Mentre con TAL ("my_row/MEDIA" è un'espressione TAL) non devi preoccuparti
se l'elemento a cui vuoi accedere è un attributo di my_row (my_row.MEDIA) o
un elemento del dizionario my_row (my_row['MEDIA']) quando usi espressioni
python (come "totale python:(totale + my_row.MEDIA)") occorre fare la
distinzione (e quindi scrivere "totale python:(totale + my_row['MEDIA'])".


             Silvio
-------------- parte successiva --------------
Un allegato HTML è stato rimosso...
URL: <http://lists.plone.org/pipermail/plone-plone-it/attachments/20110125/f1db14be/attachment-0002.html>


Maggiori informazioni sulla lista Plone-IT