[Chicago] Forms + widget support layer

DiPierro, Massimo MDiPierro at cs.depaul.edu
Fri Nov 21 18:56:55 CET 2008


web2py provides form_factory. Example:

#in model:
def mywidget(field,value): return INPUT(_name=field.name,_value-value,_style='background-color: yellow')

#in controller
form=form_factory(SQLField('name',type='string',label='Your name',default='',requires=IS_NOT_EMPTY(),widget=mywidget))

#in view
{{=form}}

there are a lot of built-in validators but you can define your own. 
All field types have default widgets (for example boolean is a checkbox, reference types are dropboxes, etc.)
'date', 'datetime', and 'time' fields have default widgets that include js popup pickers, as well as default customizable validators.

Massimo




________________________________________
From: chicago-bounces+mdipierro=cs.depaul.edu at python.org [chicago-bounces+mdipierro=cs.depaul.edu at python.org] On Behalf Of Cosmin Stejerean [cstejerean at gmail.com]
Sent: Friday, November 21, 2008 10:09 AM
To: The Chicago Python Users Group
Subject: Re: [Chicago] Forms + widget support layer

On Fri, Nov 21, 2008 at 9:58 AM, Garrett Smith <g at rrett.us.com<mailto:g at rrett.us.com>> wrote:
I'm in the market for a light weight component that sits somewhere between inbound HTTP requests and page/HTML generation that provides stuff like this:

* Encoding and decoding of widget/field values to and from HTTP/HTML land
* Field value validation
* Form validation
* Enough flexibility to support custom HTML+JavaScript widgets
* Light weight controller facility
* Not tied to a particular templating engine

z3c.forms is very much in this vein, but seems to come with sundry other z3 baggage. Maybe this isn't as bad as it sounds.

ToscaWidgets kinda does this.

And of course, Django has this sort of thing built in.

I'm looking for something along the lines of Webob -- stand alone, very light touch, but without enough support to make my life coding forms and integrating widgets much easier.

Garrett


Formencode?

--
Cosmin Stejerean
http://www.offbytwo.com


More information about the Chicago mailing list