Nested Repeats

Marco Mans <[email protected]> Mon, 25 Jul 2005 14:28:51 +0200
Newsgroups gmane.comp.web.zope.page-templates
Message-ID <[email protected]>
(Sorry... The previous one was a bit messy...)

Hi!

I got a python dictionary which can contain python-lists and other
dictionaries and so on...
Example:

a = [ {name:'Level1', subitems:[
          {name:'Item1', prop1:1, prop2:2} ,
          {'name':'Item2', prop1:3}
          {name:'Level11', subitems:[ .... ] ] ,
    ...... ]

In zope I want to display something like this:
Level1
 - Item1
 - Item2
   - Level 11
     - Item 111
     - Item 112
   - Level 12
     - Item 111
     - Item 112
   - Level X
     -Item X

The problem is that I don't know how much nested levels I got.
In python I would write a script that calls itself:
(I've not tested this example, it's just to demonstrate the
concept that I would use in python!)

def printAllLevels(listItems):
for listItem in listItems:
  print listItems['name']
  if listItem[name][:5]='Level':
    printAllLevels(listItem)

Can I do something like that with ZPT's? I was thinking of making
a macro which can call itself. But than I don't know how to parse
a variable to a macro...

Has anybody got a suggestion of how I can do this???

Thanks in advance!

Marco Mans




_______________________________________________
ZPT mailing list
[email protected]
http://mail.zope.org/mailman/listinfo/zpt