Re: Form field processing

2011-11-21 Thread Iain Duncan
fwiw, we use formencode heavily. The facilities for encoding and decoding nested form variable names are really really well designed. iain On Mon, Nov 14, 2011 at 11:47 PM, Chris McDonough wrote: > On Mon, 2011-11-14 at 23:18 -0800, uday wrote: > > Thanks for the suggestion. Is it really that

Re: Form field processing

2011-11-14 Thread Chris McDonough
On Mon, 2011-11-14 at 23:18 -0800, uday wrote: > Thanks for the suggestion. Is it really that hard to implement this? > I work with rails in my day job, it has this feature which reduces lot > of verbose code in controllers > and also it makes form handling so easy. There are a lot of form librar

Re: Form field processing

2011-11-14 Thread Eric Rasmussen
Have you taken a look at Peppercorn (http://plope.com/peppercorn)? It offers a way to deserialize forms that is closer to what you're asking, though not an exact match. But I think this might be a case where there's no direct translation from other languages/frameworks into Python/Pyramid. To see

Re: Form field processing

2011-11-14 Thread uday
This is different from what I am asking. On Nov 14, 11:29 pm, Chris McDonough wrote: > On Mon, 2011-11-14 at 13:27 -0500, Chris McDonough wrote: > > On Mon, 2011-11-14 at 12:21 -0600, Michael Merickel wrote: > > > The "key[subkey]" syntax is not supported in WebOb (I think). > > > Yeah, sorry.  I

Re: Form field processing

2011-11-14 Thread uday
Thanks for the suggestion. Is it really that hard to implement this? I work with rails in my day job, it has this feature which reduces lot of verbose code in controllers and also it makes form handling so easy. On Nov 15, 12:04 am, Gael Pasgrimaud wrote: > On Mon, Nov 14, 2011 at 7:37 PM, Mich

Re: Form field processing

2011-11-14 Thread Gael Pasgrimaud
On Mon, Nov 14, 2011 at 7:37 PM, Michael Merickel wrote: > uday, I think you'll want to just prefix your values, then you can iterate > over the POST and turn it into a dictionary: > > > profile = {} > for k in request.POST.keys(): >     if k.startswith('profile-'): >         profile[k[len('prof

Re: Form field processing

2011-11-14 Thread Michael Merickel
uday, I think you'll want to just prefix your values, then you can iterate over the POST and turn it into a dictionary: profile = {} for k in request.POST.keys(): if k.startswith('profile-'): profile[k[len('profile-'):]] = request.POST.get(k) name = profile.get('name', 'Bob') On Mo

Re: Form field processing

2011-11-14 Thread Chris McDonough
On Mon, 2011-11-14 at 13:27 -0500, Chris McDonough wrote: > On Mon, 2011-11-14 at 12:21 -0600, Michael Merickel wrote: > > The "key[subkey]" syntax is not supported in WebOb (I think). > > Yeah, sorry. I meant that when you do this in a form: > > > > > You can do in a view: > > request.getal

Re: Form field processing

2011-11-14 Thread Chris McDonough
On Mon, 2011-11-14 at 12:21 -0600, Michael Merickel wrote: > The "key[subkey]" syntax is not supported in WebOb (I think). Yeah, sorry. I meant that when you do this in a form: You can do in a view: request.getall('foo') > > On Mon, Nov 14, 2011 at 11:41 AM, Chris McDonough > wrote: >

Re: Form field processing

2011-11-14 Thread Michael Merickel
The "key[subkey]" syntax is not supported in WebOb (I think). On Mon, Nov 14, 2011 at 11:41 AM, Chris McDonough wrote: > On Mon, 2011-11-14 at 09:28 -0800, Mengu wrote: > > actually, pylons had this. it was request.params.getall('param') but > > pyramid does not support this. > > It does, actual

Re: Form field processing

2011-11-14 Thread Chris McDonough
On Mon, 2011-11-14 at 09:28 -0800, Mengu wrote: > actually, pylons had this. it was request.params.getall('param') but > pyramid does not support this. It does, actually. It's a WebOb feature (both Pyramid and Pylons use WebOb). - C > > On Nov 14, 6:12 pm, Gael Pasgrimaud wrote: > > Hi, > >

Re: Form field processing

2011-11-14 Thread Gael Pasgrimaud
Are your sure ? WebOb still have this feature: https://github.com/Pylons/webob/blob/master/webob/multidict.py#L96 But that's two different behaviors. .getall() return a list of all values for the same field (two with the same name) On Mon, Nov 14, 2011 at 6:28 PM, Mengu wrote: > actually, pylon

Re: Form field processing

2011-11-14 Thread Mengu
actually, pylons had this. it was request.params.getall('param') but pyramid does not support this. On Nov 14, 6:12 pm, Gael Pasgrimaud wrote: > Hi, > > Are you coming from php ? :) > > WebOb does not handle arrays/hashes and I don't think that this is in > the current roadmap. > > > > > > > > On

Form field processing

2011-11-14 Thread uday
Hi all, I think it is more helpful if we can make form fields processing more convenient which can reduce verbosity in views. for example assume profile model/table has fields username and password in my form i write like so when this form is submitted, it would be cool if I can just do li

Re: Form field processing

2011-11-14 Thread Gael Pasgrimaud
Hi, Are you coming from php ? :) WebOb does not handle arrays/hashes and I don't think that this is in the current roadmap. On Mon, Nov 14, 2011 at 7:52 AM, uday wrote: > Hi  all, > > > I think it is more helpful if we can make form fields processing more > convenient which can reduce verbosity