gavo.formal.form module¶
Form implementation and high-level renderers.
- class gavo.formal.form.Action(callback, name, validate, label)[source]¶
Bases:
object
Tracks an action that has been added to a form.
- class gavo.formal.form.AddHelperMixin[source]¶
Bases:
object
A mixin that provides methods for common uses of add(…).
- class gavo.formal.form.Field(name, type, widgetFactory=None, label=None, description=None, cssClass=None, form=None, default=None)[source]¶
Bases:
object
- itemParent = None¶
- property key¶
- class gavo.formal.form.FieldFragment(field)[source]¶
Bases:
CommonRenderers
,Element
- class gavo.formal.form.Form(callback=None)[source]¶
Bases:
AddHelperMixin
,object
- actions = None¶
- callback = None¶
- class gavo.formal.form.FormItems(itemParent)[source]¶
Bases:
object
A managed collection of form items.
- class gavo.formal.form.FormRenderer(original, *a, **k)[source]¶
Bases:
CommonRenderers
- loader = <twisted.web._template_util.TagLoader object>¶
- class gavo.formal.form.FormsResourceBehaviour(**k)[source]¶
Bases:
object
I provide the IResource behaviour needed to process and render a page containing a Form.
- locateForm(request, name)[source]¶
Locate a form by name.
Initially, forms are located by looking for a form_<name> attribute in our parent. Once a form has been found, we cache it in request.
This ensures that the form that is located during form processing will be the same instance that is located when a form is rendered after validation failure.
- class gavo.formal.form.Group(name, label=None, description=None, cssClass=None, form=None)[source]¶
Bases:
object
- itemParent = None¶
- property key¶
- class gavo.formal.form.ResourceWithForm[source]¶
Bases:
TemplatedPage
A t.w Resource with a template that has one or more forms.
To handle serious errors occurring during form processing, override the crash(failure, request) method. More benign errors are handled through form errors are and being rendered into the normal form.
By default, GET requests do not run actions. If your actions don’t change state, you should be ok with setting a class variable processOnGET, though.
- processOnGET = False¶
- render(request, customCallback=None)[source]¶
Render a given resource. See L{IResource}’s render method.
I delegate to methods of self with the form ‘render_METHOD’ where METHOD is the HTTP that was used to make the request. Examples: render_GET, render_HEAD, render_POST, and so on. Generally you should implement those methods instead of overriding this one.
render_METHOD methods are expected to return a byte string which will be the rendered page, unless the return value is C{server.NOT_DONE_YET}, in which case it is this class’s responsibility to write the results using C{request.write(data)} and then call C{request.finish()}.
Old code that overrides render() directly is likewise expected to return a byte string or NOT_DONE_YET.
@see: L{IResource.render}