Hi Jorge
Thanks for taking the time to reply...
Jorge Godoy wrote:
Glenn Davy <[EMAIL PROTECTED]> writes:
> 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?
It isn't. A widgets.WidgetsList is a common Python list.
ok - this raises a couple of issues for me, but i'll take this to the
python list
> 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.
Turn
client=widgets.SingleSelectField(validator=validators.NotEmpty, \
options=get_client_list_as_options)
into
client=widgets.SingleSelectField(validator=validators.NotEmpty,
default=3,
options=get_client_list_as_options)
It should select option with id 3 (not the third option) if it is available,
otherwise the selected option is browser dependent (some select the lowest ID,
some select the first option on the list -- those might be the same if there's
an option without an id ;-)).
Yep - tried this - made no diff, sorry thought I mentioned that in OP.
I found that by taking 'default=' out all together and naming a
clientID it all 'just came good'
> 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.
It isn't. You should pass values to your widgets, not change it like that.
OK, thanks
> So the question is how do I change this, or any other value in the
> controller in a 'thread safe' way?
In your template:
<span py:replace="my_widget(value)" />
In your controller:
values = dict(
option = new_value,
...
)
...
return dict(
...
value=values
...
)
hmm... Im clearly missing something, (or many somethings). The template
is just:
<body>
${form(value=values,action=action)}
</body>
and there is clearly no access to the select widget in there.
Unless you meant the tampering with the 'out of box widget', or using
it to base my own?
Am hoping to get to that next w/end, but till then surley I shoudnt
need to do that? However, as mentioned above the 'default' issue got
'fixed' by using correct fieldname, so I dont want to take more of your
time on something academic for time being. I'll raise again when/if
live issue again.
There are docs explaining all the process. I believe that even the 20 minute
wiki shows that... There are some widgets tutorials available on
docs.turbogears.org as well. Take some time to read them.
yeah thanks, sure you mean well by that last comment - I had my printed
TurboGears book open, and the pdf drafts, flicking between
contradictory (or so it seems to me) wiki pages (which are really just
worked examples - useful, but not coherent documentation) and mail list
posts. Really the __only__ way to learn tg widgets is to try'em break
'em and fix 'em.
Thanks again Jorge
Glenn
--
Jorge Godoy <[EMAIL PROTECTED]>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---