I already found a better way using a callable !
def get_contact_list():
return tg.request.contact_list
class FormMonitor(forms.TableForm):
class fields(WidgetsList):
contact_id = forms.SingleSelectField(label='Contact',
options=get_contact_list)
On 28 mai, 19:04, aspineux <[email protected]> wrote:
> I need to fill in a combo with contacts,
> these contacts depend of the service_id I get from the URL
>
> I first define my own SingleSelectField class and define the
> "update_params"
>
> class ContactSelect(forms.SingleSelectField):
>
> def update_params(self, d):
> d['options']=tg.request.contact_list
> forms.SingleSelectField.update_params(self, d)
> return d
>
> I use the tg.request.contact_list to initialize my list.
> I have previously build this list in my controller
>
> in my controller
>
> @expose('project.templates.monitor')
> def new(self, service_id, *args, **kwarg):
> ...
> tg.request.contact_list=get_contacts_for_service(service_id)
> ...
> return dict(
> ....
> )
>
> This is simple and efficient but I dont like the way I do it !
>
> - their could be a name conflict with other variable in tg.request.*
> maybe I could use another tg or pylon "container" to store my
> contact_list ?
> - The ContactSelect class is not very easy to package
>
> Any better way ?
--
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?hl=en.