[Twisted-Python] woven nested lists

Donovan Preston dp at twistedmatrix.com
Wed Dec 18 11:36:20 EST 2002

On Wednesday, December 18, 2002, at 06:26  AM, Glyph Lefkowitz wrote:
> As it happens, I discovered a woven bug in the process :-).  The code  
> here has
> 2 embedded templates ('template' and 'brokenTemplate'), one of which  
> works with
> CVS as of a few days ago and one of which works with CVS as of a few  
> minutes
> ago.  You can see my commit message about that if you're interested in  
> the
> details:
> http://www.twistedmatrix.com/pipermail/twisted-commits/2002-December/ 
> 005021.html

This bug stems from the fact that the List widget used to call getNode  
itself, thus finding only the first node below it's template node.  
getPattern will find all the pattern nodes below the widget's template  
node. The noNesting fix is a great solution, and hopefully will be  
enough of a fix.

Regarding the comment about anonymous lists: The outer list in this  
case is available using the name "mytable". So the template could be as  

<table model="mytable" view="List">
	<tr listItemOf="mytable" view="List">
		<td pattern="listItem" view="Text">

It's only the inner lists that are truly anonymous, because as the List  
widget is iterating the outer list, it sets the model attribute of the  
pattern nodes to model="0" model="1" model="2" etc. My first thought is  
to allow this type of syntax:

<table model="mytable" view="List">
	<tr listItemOf="mytable" view="List">
		<td listItemOf="." view="Text">

Which would mean "the inner node is a pattern node with the name of the  
model on top of the model stack", but I'm not sure what that buys us  
over the current noNesting fix (which certainly is the way things  
should have worked, and is the way the code worked before the  
introduction of getPattern)

By the way, there is a test of nested lists in test_woven.py. It just  
counts the number of copied nodes, however, and should probably be  
updated to check that the *correct* nodes were copied.

Thanks Glyph

More information about the Twisted-Python mailing list