Form building

class genshi_forms.form.Form

Create a subclass of Form to define custom forms:

class MyForm (Form):
        name = genshi_forms.TextField ()
        age = genshi_forms.IntegerField ()

Then call the bound() or unbound() methods to create a RenderableForm, which can be rendered into a Genshi template.

static unbound(defaults={})
Create an UnboundForm, with the given defaults.
static bound(post, files)
Create a BoundForm object, with the given uploaded user data.
static from_request(request)
Creating a BoundForm from a Django request object.
clean(post, files)

Convert post and files into a tuple (cleaned, errors).

post is a map of (FieldName -> [POST Value]). files is a map of Django-style file objects, also indexed by field name.

cleaned is a mapping of processed data, indexed by field name. errors is a map of (FieldName -> [Error messages]).

class genshi_forms.form.RenderableForm

A form that can be rendered into a Genshi markup stream.

enctype
The string to use for the enctype attribute in a <form> element.
fields
A dictionary of BoundField objects, indexed by field name.
errors
A dictionary of lists of error messages. If the form is valid, this will be an empty dictionary.
is_valid
Boolean: whether or not the form is valid. A form is valid if no errors were encountered when cleaning its data.
cleaned_data
A dictionary of processed data values. This attribute will not be present if the form is invalid.

Once a RenderableForm has been created from a Form, pass it to a template and render it:

<form enctype="${myform.enctype}">${myform.render ()}</form>
render(layout='div')
Render a form into a Genshi markup stream, using the given layout type. Available layouts are div and table.

Implementation details

class genshi_forms.form.RenderableField

A field that can be rendered to a Genshi markup stream.

name
field
id_prefix
needs_multipart
class genshi_forms.form.BoundForm
Inherits from RenderableForm.
class genshi_forms.form.UnboundForm
Inherits from RenderableForm.
class genshi_forms.form.BoundField

A RenderableField which has been bound to user-defined data.

post
files
errors
class genshi_forms.form.UnboundField

A RenderableField which doesn’t have any user-supplied data.

default