On Wed, Apr 05, 2000 at 05:01:48PM -0400, R. David Murray wrote:
On Wed, 5 Apr 2000, Andrew Diller wrote:
The scenario: an external method returns a tuple full of stuff(lists and dictionaries), and I want to tear it down and format it using DTML fors and DTML ifs, but I don't see anyone talking about doing this.
dtml-in is the tag you want. It will happily iterate over a tuple or list (and it does something with dictionaries ('mappings'), see the mapping keyword). And of course you can pythoically manipulate your data objects inside a dtml-if expression.
Thanks, that's a start, but I'm still not seeing how I can tear into say, for example a tuple of lists of lists. Here is a snippet: --------------------- <dtml-let results="my_external_method(something, more, abitmore)"> <table bgcolor=lightyellow> <dtml-in results> <TR> <TD>results#<dtml-var sequence-index>,<dtml-var sequence-number> = </TD> <TD><dtml-var sequence-item></TD> <TD><dtml-var sequence-key><TD> </TR> </dtml-in> </table> </dtml-let> ----------------------- this external method returns a tuple of items, these items themselves are compsed of three items, one of which it itself a big list containing some other lists, a dictionary and some elements. The above code, if queried with info that returns a tuple of two elements- sequence-item contains the two tuples, where I think it should _only_ have the current item in the tuple. sequence-key, however, has the _first_ item of the tuple. What I am I trying to do is: (pythonic code) let RESULTS be a tuple returned by my external method for x in results: for y in x: print y[0] print y[1] for z in y[2]: print z I can't see how you address items inside the tuple that you initially have. Does someone have some examples? -andy diller