wondering if any one can help me make sense of a couple of things. I
have this block of code in controllers.py out side of root class.
----
def get_client_list_as_options():
options = [(client.id, client.clientName) for client in
Client.select()]
return options
class ProjectFields(widgets.WidgetsList):
title=widgets.TextField(validator=validators.NotEmpty)
client=widgets.SingleSelectField(validator=validators.NotEmpty, \
options=get_client_list_as_options)
project_formwidget =
widgets.TableForm(fields=ProjectFields(),submit_text="Save Project")
-----
where im heading is to have a select list allowing a client to be
selected for a project
In the controller, I want to, when appropriate, set the 'default' or
'selected' item in the select list. I have 3 things I need answered.
1) Id __like__ to say:
project_formwidget.fields.client.default=p.clientID
However the 500 err tells me that:
AttributeError: 'ProjectFields' object has no attribute 'client', but
clearly it does. How is it that fields.client isn't an attribute?
2) How do I actually designate the 'selected' option? I passed in
'default=3' in the definition of ProjectFields.client as this is what
seems to be done in most examples I could find, but it doesnt seem to
make a difference.
3) By playing in tg-admin shell and importing controllers, I find that I
can use:
project_formwidget.fields[1].default=p.clientID
But it has no effect (as mentioned in 2)), except on one occasion to
give me a 500 error and tell me that changing this wasnt thread safe.
So the question is how do I change this, or any other value in the
controller in a 'thread safe' way?
I should also mention im using trunk
thanks
Glenn
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---