[Twisted-Python] RFC - List hierarchies in Woven

Abe Fettig abe at fettig.net
Mon Aug 11 00:11:07 MDT 2003


Attached you'll find a patch for twisted.web.woven.widgets.  This patch
is designed to let the List view handle hierarchical data, and therefore
generate tree structures and menus instead of plain lists.

Currently this patch works by checking each Model object within a list
for a "children" attribute.  If the Model has a "children" attribute,
the List view generates a child set of nodes, using its template as the
view and the contents of the "children" attribute as the model.  

Sorry if this isn't making sense, it's past my bedtime :-/

Anyhow, there's an example attached that will hopefully illustrate what
I'm trying to say here.  Run this example without the patch, only the
top-level list is used to generate the output.  Run it with the patch,
and the complete hierarchy is rendered.

I'd like to get some feedback on this.  I'm not really happy with the
hard-coded "children" attribute thing - if there's a more
elegant/twistedish way of expressing a hierarchy of objects in Python
I'd love to know about it.

Abe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: list-demo.py
Type: text/x-python
Size: 1236 bytes
Desc: not available
URL: </pipermail/twisted-python/attachments/20030811/029cf1a4/attachment-0002.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: woven-widgets-List-patch.txt
Type: text/x-patch
Size: 797 bytes
Desc: not available
URL: </pipermail/twisted-python/attachments/20030811/029cf1a4/attachment-0002.bin>


More information about the Twisted-Python mailing list