----- Original Message ----- From: "Darran Edmundson" <dee124@rsphy1.anu.edu.au> To: <zope@zope.org> Sent: Sunday, February 13, 2000 9:40 AM Subject: [Zope] building a revisitable object list???
I'm using nested <dtml-in> blocks to descend two levels into a portion of my ZODB. I'm only interested in the leaf nodes. However, rather than act on them while "visiting", I want to conditionally store a reference to them in a python list so that I can visit any leaf later on.
This should probably be done in a PythonMethod. It's sooooo much cleaner. I used to do this kind of thing in DTML, because it was too much of a pain to make an ExternalMethod. With PythonMethods, I find it so much more user friendly to write this kind of logic directly in python.
I'll make it clear with a pared-down example.
root folder1 subfolder1a subfolder1b folder2 subfolder2a
I want to build a list such that I can visit various subfolders without having to search them out.
So the subfolders all have unique names? If so, you can build a hash: leaves = {} for folder in objectValues('Folder'): for leaf in folder.objectValues('Folder'): leaves.update({leaf.id : leaf}) After this, you can just do leaves['subfolder1a'] to get the actual subfolder1a object. Kevin