I've been working on a form generation toolkit that integrates well with FormEncode... its still under heavy development, of course, but I've seen a lot of discussion of this topic on various mailing lists over the past few days, and so wanted to get something out. Release early and all that. So you can get it from
https://developer.berlios.de/project/showfiles.php?group_id=4967 There's a README with a tutorial in there, which is also provided as a friendlier README.html. It requires FormEncode (I developed with FormEncode 0.22, but I expect it will work with older versions). Current features include default values, intelligent detection and rendering of "required" fields, extensive facilities for customization of the output markup, etc. Mainly, I've tried to make it easy to use. I'm a Cherrypy guy, and so aimed it at use with that; it should be perfectly usable with TurboGears too (although its largely orthagonal to the (problematic) way that TurboGears currently encourages you to use forms). Really, its usable with any framework that lets you access form submissions as a python dict. For a really quick intro, I've pasted the contents of a sample script that uses formulaic below, along with the output that script would produce. Its nowhere remotely near finished, of course, but hopefully is at a a point that it can be useful for real world work. Questions, suggestions, etc. are extraordinarily welcome. Greg example.py ------------- #!/usr/bin/python from formencode import validators from formencode.api import Invalid from formulaic import forms from formulaic import basicwidgets as widgets form = forms.RequirementsForm() form.attrs['id'] = 'myform' form['age'] = widgets.TextInput(validators.Int(), 'Age') form['age'].attrs = {'size':'4', 'maxlength':'3'} colors = ['Red', 'Green', 'Blue'] form['favcolor'] = widgets.Select(validators.OneOf(colors), 'Favorite color', options=colors) form['pie'] = widgets.CheckboxInput(validators.Bool(), 'I like pie') inputs = {'age':'ten', 'favcolor':'Green', 'pie':'checked'} try: data = form.schema.to_python(inputs) print data except Invalid, error: print form.render(inputs, error.error_dict) ----------------- output: <form action="" method="POST" id="myform"> <label class="required">Age</label> <input type="text" name="age" value="ten"/> <span class="error">Please enter an integer value</span> <label class="required">Favorite color</label> <select type="text" name="favcolor"> <option value="Red">Red</option> <option selected="selected" value="Green">Green</option> <option value="Blue">Blue</option> </select> <label>I like pie</label> <input type="text" checked="checked" name="pie"/> <input type="submit" value="Submit"/> </form> -- http://mail.python.org/mailman/listinfo/python-list