A library for generating and validating HTML forms
Project description
Introduction
pysform is a library designed to facilitate the rendering/processing/validating of HTML forms.
Features
validation based on FormEncode
attempting to have complete HTML spec coverage
extensible rendering system() (don’t have to use it)
will work with multiple WSGI frameworks (Werkzeug currently supported)
extensive unit tests
few dependencies: FormEncode, pysutils, WebHelpers
Code Sample
Using it might look like this:
class MyForm(Form): def __init__(self): Form.__init__(self, 'myform') el = self.add_header('input-els', 'Optional Elements') el = self.add_button('button', 'Button', defaultval='PushMe') el = self.add_checkbox('checkbox', 'Checkbox') el = self.add_file('file', 'File') el = self.add_hidden('hidden', defaultval='my hidden val') el = self.add_image('image', 'Image', defaultval='my image val', src='images/icons/b_edit.png') el = self.add_text('text', 'Text') el.add_note('a note') el.add_note('an <strong>HTML</strong> note', False) el = self.add_text('nolabel', defaultval='No Label') el.add_note('a note') el = self.add_password('password', 'Password') el = self.add_confirm('confirm', 'Confirm Password', match='password') el.add_note('confirm characters for password field are automatically masked') el = self.add_date('date', 'Date', defaultval=datetime.date(2009, 12, 3)) el.add_note('note the automatic conversion from datetime object') emel = self.add_email('email', 'Email') el = self.add_confirm('confirmeml', 'Confirm Email', match=emel) el.add_note('note you can confirm with the name of the field or the element object') el.add_note('when not confirming password field, characters are not masked') el = self.add_time('time', 'Time') el = self.add_url('url', 'URL') options = [('1', 'one'), ('2','two')] el = self.add_select('select', options, 'Select') el = self.add_mselect('mselect', options, 'Multi Select') el = self.add_textarea('textarea', 'Text Area') el = self.add_fixed('fixed', 'Fixed', 'fixed val') el = self.add_fixed('fixed-no-label', defaultval = 'fixed no label') el = self.add_static('static', 'Static', 'static val') el = self.add_static('static-no-label', defaultval='static val no label')
and the view/controller code might look something like:
class FormTest(HtmlTemplatePage): def prep(self): self.form = MyForm() def post(self): if self.form.is_cancel(): self.assign('cancel', True) elif self.form.is_valid(): self.assign('values', self.form.get_values()) elif self.form.is_submitted(): # form was submitted, but invalid self.form.assign_user_errors() self.default() def default(self): self.assign('form', self.form)
Questions & Comments
Please visit: http://groups.google.com/group/pyslibs
Current Status
The code for 0.1 is pretty stable. API, however, will be changing in 0.2.
The somewhat stable development version.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pysform-0.1.zip
.
File metadata
- Download URL: pysform-0.1.zip
- Upload date:
- Size: 43.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 80e7e1004a87f81c0d9dd04056cf9d9910a9c85ca3d39f3f59d6203583186f46 |
|
MD5 | cb90881ccdfdae407d616cc29fb2b4c9 |
|
BLAKE2b-256 | 8cd396c2213d0b3c7ceef591133881d0ad4cfbcb6f175e28164e5368a2d0d647 |
File details
Details for the file pysform-0.1-py2.5.egg
.
File metadata
- Download URL: pysform-0.1-py2.5.egg
- Upload date:
- Size: 44.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae83816b97a9942cccc77d8d6487fbad7716c1ac66e8cde6a7a0a05d00e54a97 |
|
MD5 | 3676590e471fbd54489050d9dd72f2e1 |
|
BLAKE2b-256 | 9ee22b77b3723907d3ea9301e1c2acd9450f96c41b721e4838ef775dd954ed16 |