[Twisted-Python] woven-bug: multiple nodes using the same model

Paul Boehm typo at soniq.net
Wed Oct 9 10:32:43 EDT 2002


when a controller and a widget have the same model, this leads to
lots of weird inconsistencies.

i use this template:

        <form action="" name="addserver" model="listall" controller="addserver">
            Host:
            <input type="text" name="host" />
            Port:
            <input type="text" name="port" />
            <input type="submit" value="Add" />
        </form>

        <form action="">
            <span class="heading">All Servers:</span>
            <ul model="listall" view="List">
                <li id="emptyList">No Servers defined</li>
                <li id="listItem">
                    <span view="Text" model="0" />
                    <span view="Text" model="1" />
                    <span view="CheckBox" model="2" value="1" />
                    <span view="CheckBox" model="3" value="1" />
                </li>
            </ul>
            <input type="submit" />
        </form>

This results in two calls to widgets.List.generateDOM, which produces
inconsistencies. 

I'm not sure which code is at fault, but List at least produces a wrong 
_submodel_prefix. Because of this i modified List to reset the Attribute
on every call:

#            domhelpers.superAppendAttribute(newNode, '_submodel_prefix',
#                                            submodel)
            domhelpers.superSetAttribute(newNode, '_submodel_prefix',
                                            submodel)
            domhelpers.superAppendAttribute(newNode, '_submodel_prefix',
                                            str(itemNum))

This fixes the wrong _submodel_prefix, but the List view still lags behind
one added element per submit. after a normal reload all the data is displayed
correctly.

Also all listitems get displayed with the same value every time after
submitting.

when i reload with a failing Handler.check, i get the right values, though.

i'm trying to debug this right now, but some help from someone with a
better understanding of woven's internals would be really helpful.

  paul




More information about the Twisted-Python mailing list