Skip to main content

A library for generating and validating HTML forms

Project description

Introduction

BlazeForm 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, BlazeUtils, WebHelpers

Code Sample

Using it might look like this:

class MyForm(Form):
    def __init__(self):
        Form.__init__(self, 'myform')

        el = self.els.add_header('input-els', 'Optional Elements')
        el = self.els.add_button('button', 'Button', defaultval='PushMe')
        el = self.els.add_checkbox('checkbox', 'Checkbox')
        el = self.els.add_file('file', 'File')
        el = self.els.add_hidden('hidden', defaultval='my hidden val')
        el = self.els.add_image('image', 'Image', defaultval='my image val', src='images/icons/b_edit.png')
        el = self.els.add_text('text', 'Text')
        el.add_note('a note')
        el.add_note('an <strong>HTML</strong> note', False)
        el = self.els.add_text('nolabel', defaultval='No Label')
        el.add_note('a note')
        el = self.els.add_password('password', 'Password')
        el = self.els.add_confirm('confirm', 'Confirm Password', match='password')
        el.add_note('confirm characters for password field are automatically masked')
        el = self.els.add_date('date', 'Date', defaultval=datetime.date(2009, 12, 3))
        el.add_note('note the automatic conversion from datetime object')
        emel = self.els.add_email('email', 'Email')
        el = self.els.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.els.add_time('time', 'Time')
        el = self.els.add_url('url', 'URL')
        options = [('1', 'one'), ('2','two')]
        el = self.els.add_select('select', options, 'Select')
        el = self.els.add_mselect('mselect', options, 'Multi Select')
        el = self.els.add_textarea('textarea', 'Text Area')
        el = self.els.add_fixed('fixed', 'Fixed', 'fixed val')
        el = self.els.add_fixed('fixed-no-label', defaultval = 'fixed no label')
        el = self.els.add_static('static', 'Static', 'static val')
        el = self.els.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/blazelibs

Current Status

The code stays pretty stable, but the API may change, especially the rending.

The blazeform tip is installable via easy_install with easy_install blazeform==dev

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

BlazeForm-0.3.0.tar.gz (18.8 kB view details)

Uploaded Source

Built Distribution

BlazeForm-0.3.0-py2.6.egg (52.1 kB view details)

Uploaded Source

File details

Details for the file BlazeForm-0.3.0.tar.gz.

File metadata

  • Download URL: BlazeForm-0.3.0.tar.gz
  • Upload date:
  • Size: 18.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for BlazeForm-0.3.0.tar.gz
Algorithm Hash digest
SHA256 f8f3be1c452e2f3aa647675a4439d03c914922e800fe2f436059fef5ebc9bc09
MD5 48c98126cb279f66184605717ad6d024
BLAKE2b-256 fd0d506b0b85f57c39c90dc4741f51911a08f769cb705d6b1a8d0e9c5a0abaa5

See more details on using hashes here.

Provenance

File details

Details for the file BlazeForm-0.3.0-py2.6.egg.

File metadata

File hashes

Hashes for BlazeForm-0.3.0-py2.6.egg
Algorithm Hash digest
SHA256 f7c350925ce246dd230c0ec9c7af79b0b8c133cd16a27d20bbccd9a648b5e436
MD5 9d113d2736a66d067387d7ed08641668
BLAKE2b-256 be988ce9619c1822da00a520bf34f6dcdf400c7d8d47faeb20287f766b94864c

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page