[Twisted-Python] Generate select options in woven

Philippe Lafoucrière lafou at wanadoo.fr
Mon Dec 8 01:53:40 EST 2003


On Sunday 07 December 2003 21:02, Samuel Reynolds wrote:
> Can someone help me out? I'm trying (so far without success) to get Woven
> to generate the Options for a Select from my Model. I haven't found any
> docs or examples that explain it.

You can use something like this :

<select name="display" onChange="submit()" model="versions" view="List">
   <span pattern="listItem">
       <option view="display_value" value="thevalue"><span view="Text"></span>
       </option>
   </span>
</select>


here is your simple model

def wmfactory_versions(self, request):
	return ["item1", "item2", "item3"]


This will help to autoselect the last selected value :

from twisted.web import  microdom

def wvupdate_display_value(self, request, node, model):
        option = microdom.lmx(node)
        option['value'] = model
        display = request.args.get("display", [""])[0]
        if display == model:
            option['selected'] = "1"

I hope this helps !


Regards
--
Philippe





More information about the Twisted-Python mailing list