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 <[email protected]> wrote:

> 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 libraries for Python that offer similar features
> (formencode, deform, toscawidgets, formish, and so forth).
>
> There is also http://pypi.python.org/pypi/repoze.monty/0.1 which handles
> stuff like this.
>
> If none of these are sufficent, patches, as always, are accepted.
>
> - C
>
>
> >
> >
> > On Nov 15, 12:04 am, Gael Pasgrimaud <[email protected]> wrote:
> > > On Mon, Nov 14, 2011 at 7:37 PM, Michael Merickel <[email protected]>
> 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:
> > > > <input name="profile-name"/>
> > > > <input name="profile-email"/>
> > > > profile = {}
> > > > for k in request.POST.keys():
> > > >     if k.startswith('profile-'):
> > > >         profile[k[len('profile-'):]] = request.POST.get(k)
> > > > name = profile.get('name', 'Bob')
> > >
> > > Or use a form library. FormAlchemy allow to use a prefix and I guess
> > > that deform and other libraries have way to do that too.
> > > If you need this kind of structure that mean that you want to build
> > > complex forms. Build html forms and validation stuff by hand is not
> > > really fun and not very efficient.
> > >
> > > My 2c.
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > > On Mon, Nov 14, 2011 at 12:29 PM, Chris McDonough <[email protected]>
> 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 meant that when you do this in a form:
> > >
> > > >> > <input type="text" name="foo"></input>
> > > >> > <input type="text" name="foo"></input>
> > >
> > > >> > You can do in a view:
> > >
> > > >> > request.getall('foo')
> > >
> > > >> Sorry, rather:
> > >
> > > >> request.POST.getall('foo')
> > >
> > > >> > > On Mon, Nov 14, 2011 at 11:41 AM, Chris McDonough <
> [email protected]>
> > > >> > > 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, actually.  It's a WebOb feature (both Pyramid
> and
> > > >> > >         Pylons use
> > > >> > >         WebOb).
> > >
> > > >> > >         - C
> > >
> > > >> > >         >
> > > >> > >         > On Nov 14, 6:12 pm, Gael Pasgrimaud <[email protected]>
> 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 Mon, Nov 14, 2011 at 7:52 AM, uday <
> [email protected]>
> > > >> > >         wrote:
> > > >> > >         > > > 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    <input type='text'
> > > >> > >         > > > name='profile[username']><input type='password'
> > > >> > >         > > > name='profile[password]'>
> > > >> > >         > >
> > > >> > >         > > > so when this form is submitted, it would be cool
> if I
> > > >> > >         can just do
> > > >> > >         > > > like: request.POST['profile'] which gives me a
> dict of
> > > >> > >         names and
> > > >> > >         > > > values specific to that model/table whatever
> > > >> > >         > > > so if I do request.POST['profile'] = {'username':
> value
> > > >> > >         entered by
> > > >> > >         > > > user, 'password': value entered by user}
> > > >> > >         > >
> > > >> > >         > > > is this feature already there? or can it be
> achieved in
> > > >> > >         any other way?
> > > >> > >         > > > is it related to webob or pyramid?
> > > >> > >         > > > I am ready to work on this to make it available in
> > > >> > >         pyramid, so please
> > > >> > >         > > > give me pointers to work on this.
> > > >> > >         > >
> > > >> > >         > > > --
> > > >> > >         > > > You received this message because you are
> subscribed to
> > > >> > >         the Google Groups "pylons-discuss" 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
> > > >> > >         athttp://groups.google.com/group/pylons-discuss?hl=en.
> > > >> > >         >
> > >
> > > >> > >         --
> > > >> > >         You received this message because you are subscribed to
> the
> > > >> > >         Google Groups "pylons-discuss" group.
> > > >> > >         To post to this group, send email to
> > > >> > >         [email protected].
> > > >> > >         To unsubscribe from this group, send email to
> pylons-discuss
> > > >> > >         [email protected].
> > > >> > >         For more options, visit this group at
> > > >> > >        http://groups.google.com/group/pylons-discuss?hl=en.
> > >
> > > >> > > --
> > >
> > > >> > > Michael
> > >
> > > >> > > --
> > > >> > > You received this message because you are subscribed to the
> Google
> > > >> > > Groups "pylons-discuss" group.
> > > >> > > To post to this group, send email to
> [email protected].
> > > >> > > To unsubscribe from this group, send email to pylons-discuss
> > > >> > > [email protected].
> > > >> > > For more options, visit this group at
> > > >> > >http://groups.google.com/group/pylons-discuss?hl=en.
> > >
> > > >> > --
> > > >> > You received this message because you are subscribed to the Google
> > > >> > Groups "pylons-discuss" 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/pylons-discuss?hl=en.
> > >
> > > >> --
> > > >> You received this message because you are subscribed to the Google
> Groups
> > > >> "pylons-discuss" 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/pylons-discuss?hl=en.
> > >
> > > > --
> > >
> > > > Michael
> > >
> > > > --
> > > > You received this message because you are subscribed to the Google
> Groups
> > > > "pylons-discuss" 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/pylons-discuss?hl=en.
> >
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" 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/pylons-discuss?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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/pylons-discuss?hl=en.

Reply via email to