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

Jeffrey Hood jhood@hmcon.com
Mon, 30 Jun 2003 15:38:02 -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

this gets the data and returns it in a list of lists:
[['1', 'Fido', '5.00'], ['2', 'Spot', '10.00'], ['4', 'Sparky', '24'], ['9',
'Buffy', '10'], ['10', 'Bobby', '50']]

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>

Neither of the above work... on both counts, now I get:

Exception traceback
Time 2003/06/30 15:32:49.218 US/Eastern
User Name (User Id) Anonymous User (None)
Request URL http://jhoodxp.hmcon.com:8081/jhood/show_records
Exception Type TypeError
Exception Value sequence index must be integer

Traceback (innermost last):

    * Module ZPublisher.Publish, line 98, in publish
    * Module ZPublisher.mapply, line 88, in mapply
    * Module ZPublisher.Publish, line 39, in call_object
    * Module Shared.DC.Scripts.Bindings, line 252, in __call__
    * Module Shared.DC.Scripts.Bindings, line 283, in _bindAndExec
    * Module Products.PageTemplates.ZopePageTemplate, line 228, in _exec
    * Module Products.PageTemplates.PageTemplate, line 95, in pt_render
      <ZopePageTemplate at /jhood/show_records>
    * Module TAL.TALInterpreter, line 200, in __call__
    * Module TAL.TALInterpreter, line 244, in interpret
    * Module TAL.TALInterpreter, line 497, in do_insertText_tal
    * Module Products.PageTemplates.TALES, line 223, in evaluateText
    * Module Products.PageTemplates.TALES, line 217, in evaluate
      URL: /jhood/show_records
      Line 34, Column 8
      Expression: standard:'records/item'

{'container': <Folder instance at 01EAAC68>,
 'default': <Products.PageTemplates.TALES.Default instance at 008AFF6C>,
 'here': <Folder instance at 01EAAC68>,
 'loop': <SafeMapping instance at 01F62578>,
 'modules': <Products.PageTemplates.ZRPythonExpr._SecureModuleImporter
instance at 008B0024>,
 'nothing': None,
 'options': {'args': ()},
 'repeat': <SafeMapping instance at 01F62578>,
 'request': <HTTPRequest,
 'root': <Application instance at 019B27C8>,
 'template': <ZopePageTemplate at /jhood/show_records>,
 'traverse_subpath': [],
 'user': Anonymous User}

    * Module Products.PageTemplates.Expressions, line 206, in __call__
    * Module Products.PageTemplates.Expressions, line 194, in _eval
    * Module Products.PageTemplates.Expressions, line 150, in _eval
      __traceback_info__: records
    * Module Products.PageTemplates.Expressions, line 353, in
      __traceback_info__: {'path': ['item'], 'TraversalRequestNameStack':

TypeError: sequence index must be integer

It seems (to me with my limited python/zope knowledge) that the tal is
looking for something other than a list of lists, and it can't handle it... 
although now at least I don't have security issues...  

Question is...  what can I do ???  If I have to change the return value,
what should it be, and if I can use it, how can I use it with tal...  

This is driving me mad, since I *really* would like to use Zope for a
project, but this is almost getting too frustrating...

Thanks in advance...


jhood .a.
hmcon .d. com