On Oct 24, 2006, at 11:10 PM, Fernando Aires wrote:

>
> Hello,
>
>    I have a previously instantiated widget (particularly a
> SingleSelectField), and need to change one of its parameters
> (particularly the options attribute). To do it straightly generates an
> exception.
>    I found at the list archives one patch from last January, from
> Michele Celia, proposing a change. However, there's any other way of
> doing so, without redefining the widget?
>
> Sincerely,

Changing the parameter on the widget is not possible, nor desirable,  
it wouln't be thread-safe because widget instances are shared among  
threads.

However, you can override most parameters on a per-request basis just  
by passing them as keyword arguments to display:

${select_field.display(options=new_options)}

You can also initialize your select field passing a callable as the  
options parameter which can return fresh options for each request:

def players():
        return [(p.id, p.name) for p in Player.select()]

select_field = SingleSelectField("goalie", options=players)

Alberto

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---

Reply via email to