kotti.views.form

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, **kw)[source]

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

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

A basic view for forms with save and cancel buttons.

form_class

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(
        colander.String(),
        title=u'Body',
        widget=RichTextWidget(),
        missing=u'',
        )

class DocumentEditForm(EditFormView):
    schema_factory = DocumentSchema
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 = u'Document'
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.

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.