Form related base views from which you can inherit.

Inheritance Diagram

Inheritance diagram of kotti.views.form

class kotti.views.form.ObjectType[source]

A type leaving the value untouched.

class kotti.views.form.Form(schema, action='', method='POST', buttons=(), formid='deform', use_ajax=False, ajax_options='{}', autocomplete=None, focus='on', **kw)[source]

A deform Form that allows ‘appstruct’ to be set on the instance.

render(appstruct=None, readonly=False)[source]

Render the field (or form) to HTML using appstruct as a set of default values and returns the HTML string. appstruct is typically a dictionary of application values matching the schema used by this form, or colander.null to render all defaults. If it is omitted, the rendering will use the appstruct passed to the constructor.

Calling this method passing an appstruct is the same as calling:

cstruct = form.set_appstruct(appstruct)
form.serialize(cstruct, **kw)

Calling this method without passing an appstruct is the same as calling:

cstruct = form.cstruct
form.serialize(cstruct, **kw)

See the documentation for colander.SchemaNode.serialize() and deform.widget.Widget.serialize() .


Deform versions before 0.9.8 only accepted a readonly keyword argument to this function. Version 0.9.8 and later accept arbitrary keyword arguments.

class kotti.views.form.BaseFormView(context, request, **kwargs)[source]

A basic view for forms with save and cancel buttons.


alias of Form

class kotti.views.form.EditFormView(context, request, **kwargs)[source]

A base form for content editing purposes.

Set self.schema_factory to the context’s schema. Values of fields in this schema will be set as attributes on the context. An example:

import colander
from deform.widget import RichTextWidget

from kotti.edit.content import ContentSchema
from kotti.edit.content import EditFormView

class DocumentSchema(ContentSchema):
    body = colander.SchemaNode(

class DocumentEditForm(EditFormView):
    schema_factory = DocumentSchema

Performs some processing on the form prior to rendering.

By default, this method does nothing. Override this method in your dervived class to modify the form. Your function will be executed immediately after instansiating the form instance in __call__() (thus before obtaining widget resources, considering buttons, or rendering).

class kotti.views.form.AddFormView(context, request, **kwargs)[source]

A base form for content adding purposes.

Set self.schema_factory as with EditFormView. Also set item_type to your model class. An example:

class DocumentAddForm(AddFormView):
    schema_factory = DocumentSchema
    add = Document
    item_type = 'Document'
class kotti.views.form.CommaSeparatedListWidget(template=None, **kw)[source]
serialize(field, cstruct, readonly=False)[source]

The serialize method of a widget must serialize a cstruct value to an HTML rendering. A cstruct value is the value which results from a Colander schema serialization for the schema node associated with this widget. serialize should return the HTML rendering: the result of this method should always be a string containing HTML. The field argument is the field object to which this widget is attached. The **kw argument allows a caller to pass named arguments that might be used to influence individual widget renderings.

static deserialize(field, pstruct)[source]

The deserialize method of a widget must deserialize a pstruct value to a cstruct value and return the cstruct value. The pstruct argument is a value resulting from the parse method of the Peppercorn package. The field argument is the field object to which this widget is attached.

class kotti.views.form.FileUploadTempStore(request)[source]

A temporary storage for file file uploads

File uploads are stored in the session so that you don’t need to upload your file again if validation of another schema node fails.

keys() → a set-like object providing a view on D's keys[source]
kotti.views.form.validate_file_size_limit(node, value)[source]

File size limit validator.

You can configure the maximum size by setting the kotti.max_file_size option to the maximum number of bytes that you want to allow.