[Zope] zope tal / external method woes continued...

Dieter Maurer dieter@handshake.de
Fri, 4 Jul 2003 20:34:18 +0200


Jeffrey Hood wrote at 2003-6-30 15:38 -0400:
 > I (finally) got my permissions problem with my external method solved, by
 > changing the ext method to return a list of lists:
 > 
 > def getAll:
 >    rows = ... # get data from soap call
 >    results []
 >    for row in rows
 >       results.append( row[0], row[1], row[2] )
 >    return results

Strange that this works. I would expect a "TypeError: 'append' takes
a single argument".

 > ...
 > my tal code looks like the following:
 > 
 > 
 >   <p tal:content="here/getRecords"> </p>
 > 
 >     <table border="1" tal:define="data python:here.getRecords()">
 >     <tr tal:repeat="record data">  
 >         <td tal:content="python:record[0]">record item 1</td>
 >         <td tal:content="python:record[1]">record item 2</td>
 >         <td tal:content="python:record[2]">record item 3</td>
 >     </tr>
 >     </table>
 > ...
 > -------------------------------------------------------------------
 > Exception traceback
 > ...
 >       URL: /jhood/show_records
 >       Line 34, Column 8
 >       Expression: standard:'records/item'
 >       Names:
 > ...
 > restrictedTraverse
 >       __traceback_info__: {'path': ['item'], 'TraversalRequestNameStack':
 > []}
 > 
 > TypeError: sequence index must be integer

Your code extract does not correspond to this traceback.

   In line 34 of "show_records" you use "records/item" (which does not
   occur in your code extract).
   There, "records" is a sequence but 'item' is a string.
   This results in the  TypeError you observe.

   Unless you access the built in methods of a sequence (e.g. of
   a list), you must use "python:" expressions to access sequence
   components.


Dieter