>
>         form[0].insert(-1,element)
>

I see, you're not inserting into the form object but into the form[0] 
object, which is a TABLE object. The components of a TABLE must be a TR, 
TBODY, THEAD, etc. When you call the insert() method, it calls the _fixup() 
method, which then calls the _wrap_components() method, which loops through 
each component of the table and makes sure it is one of the allowed 
components (and wraps it in a TR if it is not). When you are inserting a 
large number of components into the TABLE one at a time, this is 
inefficient because it loops through all previously inserted components 
each time even though only the one currently being inserted needs to be 
wrapped. This should probably be handled differently, but it's not really a 
problem unless the object contains a lot of components (i.e., your case).

One workaround might be something like:

    element = TR(TD(INPUT(_name=net.name + str(net.id), value=net.checked,_type
='checkbox')))
    form[0].components.insert(-1, element)

That inserts directly into form[0].components instead of form[0]. 
form[0].components is just a list, so inserting directly into it doesn't 
call the _wrap_components() method. However, because _wrap_components 
doesn't get called, you have to manually wrap the INPUT element in a TD and 
a TR before inserting into the TABLE object (note, this assumes you are 
using the table formstyle for the form -- you would have to wrap in LI or 
DIV if using one of those formstyles).

Anthony

Reply via email to