Jonathan LaCour wrote:
> Mark Ramm wrote:
>
>> The fact that TurboGears turns incoming request prams into
>> controller function params seems intuitive and smart to me. But
>> there are some limitations:
>>
>> * Function params must have asci string names
>> * Function params can have only one value
>
> I actually think the first problem is irrelevant. As Diez suggests
> later, this can be controlled by the developer, and I believe that
> if the developer really needs non-ascii parameter names, they can
> just take in `**params` rather than explicitly defining them in the
> method.
You can't get unicode even via **params. Encoded strings work okay,
though. I.e.:
# doesn't work:
dict(**{u'\u1000': 'foo'})
# even this doesn't work:
dict(**{u'foo': 'foo'})
# This does work:
dict(**{u'\u1000'.encode('utf8'): 'foo'})
However, I thought WebOb wouldn't give you unicode keys by default. You
need to set decode_params_names = True on the request to get that.
> The second problem is a genuine issue, and one that bit me just
> today. I think that we should solve this at a higher level, and
> parameters that have multiple values should just come through as a
> list of the values. I am working around this right now by using
> `request.params` and it works fine for me for the time being.
If you use request.params.mixed() to get the keyword arguments, you'll
get lists in these cases. Some people find that frustrating, as things
may be lists or not (e.g., one checkbox checked is not a list, two are),
or misformed submissions cause TypeErrors and whatnot when you
unexpectedly get multiple values. Anyway, that's the justification
(along with ordering and some other things) for not using a plain dict
as the form representation.
Ian
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears Trunk" 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-trunk?hl=en
-~----------~----~----~----~------~----~------~--~---