• Stars
    star
    400
  • Rank 103,788 (Top 3 %)
  • Language
    JavaScript
  • License
    Other
  • Created about 13 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Python HTML form library.

Deform

Build Status

Current Release

Main Documentation Status

Latest Documentation Status

Python Support

local

Introduction

Deform is a Python form library for generating HTML forms on the server side. Date and time picking widgets, rich text editors, forms with dynamically added and removed items and a few other complex use cases are supported out of the box.

Deform integrates with the Pyramid web framework and several other web frameworks. Deform comes with Chameleon templates and Bootstrap 5 styling. Under the hood, Colander schemas are used for serialization and validation. The Peppercorn library maps HTTP form submissions to nested structure.

Although Deform uses Chameleon templates internally, you can embed rendered Deform forms into any template language.

Use cases

Deform is ideal for complex server-side generated forms. Potential use cases include:

  • Complex data entry forms
  • Administrative interfaces
  • Python based websites with high amount of data manipulation forms
  • Websites where additional front end framework is not needed

Installation

Install using pip and Python package installation best practices:

pip install deform

Example

See all widget examples. Below is a sample form loop using the Pyramid web framework.

image

Example code:

"""Self-contained Deform demo example."""
from __future__ import print_function

from pyramid.config import Configurator
from pyramid.session import UnencryptedCookieSessionFactoryConfig
from pyramid.httpexceptions import HTTPFound

import colander
import deform


class ExampleSchema(deform.schema.CSRFSchema):

    name = colander.SchemaNode(
        colander.String(),
        title="Name")

    age = colander.SchemaNode(
        colander.Int(),
        default=18,
        title="Age",
        description="Your age in years")


def mini_example(request):
    """Sample Deform form with validation."""

    schema = ExampleSchema().bind(request=request)

    # Create a styled button with some extra Bootstrap 3 CSS classes
    process_btn = deform.form.Button(name='process', title="Process")
    form = deform.form.Form(schema, buttons=(process_btn,))

    # User submitted this form
    if request.method == "POST":
        if 'process' in request.POST:

            try:
                appstruct = form.validate(request.POST.items())

                # Save form data from appstruct
                print("Your name:", appstruct["name"])
                print("Your age:", appstruct["age"])

                # Thank user and take him/her to the next page
                request.session.flash('Thank you for the submission.')

                # Redirect to the page shows after succesful form submission
                return HTTPFound("/")

            except deform.exception.ValidationFailure as e:
                # Render a form version where errors are visible next to the fields,
                # and the submitted values are posted back
                rendered_form = e.render()
    else:
        # Render a form with initial default values
        rendered_form = form.render()

    return {
        # This is just rendered HTML in a string
        # and can be embedded in any template language
        "rendered_form": rendered_form,
    }


def main(global_config, **settings):
    """pserve entry point"""
    session_factory = UnencryptedCookieSessionFactoryConfig('seekrit!')
    config = Configurator(settings=settings, session_factory=session_factory)
    config.include('pyramid_chameleon')
    deform.renderer.configure_zpt_renderer()
    config.add_static_view('static_deform', 'deform:static')
    config.add_route('mini_example', path='/')
    config.add_view(mini_example, route_name="mini_example", renderer="templates/mini.pt")
    return config.make_wsgi_app()

This example is in deformdemo repository. Run the example with pserve:

pserve mini.ini --reload

Status

This library is actively developed and maintained. Deform 2.x branch has been used in production on several sites since 2014. Automatic test suite has 100% Python code coverage and 500+ tests.

Projects using Deform

More Repositories

1

pyramid

Pyramid - A Python web framework
Python
3,834
star
2

waitress

Waitress - A WSGI server for Python 3
Python
1,310
star
3

colander

A serialization/deserialization/validation library for strings, mappings and lists.
Python
439
star
4

webob

WSGI request and response objects
Python
426
star
5

webtest

Wraps any WSGI application and makes it easy to send test requests to that application, without starting up an HTTP server.
Python
330
star
6

pylons

Pylons Framework, community maintained with guidance/assistance from the Pylons Project. Merged with repoze.bfg for Pyramid framework.
Python
230
star
7

hupper

in-process file monitor / reloader for reloading your code automatically during development
Python
204
star
8

pyramid_cookbook

Pyramid cookbook recipes (documentation)
Python
182
star
9

substanced

An application server based on the Pyramid web framework (http://substanced.net)
Python
151
star
10

shootout

Pyramid sample application: shootout "idea competition" application
Python
106
star
11

pyramid_debugtoolbar

Pyramid debug toolbar
Python
94
star
12

pyramid-cookiecutter-starter

A Cookiecutter (project template) for creating a Pyramid starter project with choices for template language (Jinja2, Chameleon, or Mako), persistent backend (none, SQLAlchemy with SQLite, or ZODB), and mapping of URLs to routes (URL dispatch or traversal)
Python
92
star
13

pyramid_tutorials

Tutorials for Pyramid
Python
88
star
14

pyramid_openapi3

Pyramid addon for OpenAPI3 validation of requests and responses.
Python
81
star
15

pylonsrtd

Pylons Project documentation on RTD
Python
74
star
16

pyramid_jinja2

Jinja2 templating system bindings for the Pyramid web framework
Python
72
star
17

pyramid_blogr

Pyramid_blogr is an example implementation of Flaskr app with Pyramid Web Framework
Python
71
star
18

paginate

Python pagination module
Python
70
star
19

venusian

A library which allows framework authors to defer decorator actions.
Python
67
star
20

pyramid_beaker

Beaker sessioning bindings for Pyramid
Python
50
star
21

pyramid_mailer

A package for sending email from your Pyramid application
Python
50
star
22

acidfs

GIT on ACID. Use the fileystem from Python in a transactional, consistent way using Git.
Python
42
star
23

deformdemo

Deform form generation framework demo application
Python
42
star
24

pylonshq

pylonsproject.org website
Python
41
star
25

paginate_sqlalchemy

Extension to the Python 'paginate' module to work with SQLAlchemy objects
Python
40
star
26

pyramid-cookiecutter-alchemy

[DEPRECATED - Please use https://github.com/pylons/pyramid-cookiecutter-starter instead] A Cookiecutter (project template) for creating a Pyramid project using SQLite for persistent storage, SQLAlchemy for an ORM, Alembic for database migrations, URL dispatch for routing, and Jinja2 for templating.
Python
40
star
27

pyramid_deform

Bindings for the Pyramid web framework to the Deform form generation package.
Python
36
star
28

peppercorn

A library for converting a token stream into a data structure comprised of sequences, mappings, and scalars, developed primarily for converting HTTP form post data into a richer data structure.
Python
34
star
29

pyramid_tm

Centralized transaction management for Pyramid applications (without middleware)
Python
33
star
30

hypatia

Python searching and indexing library.
Python
29
star
31

cluegun

A sample pastebin application for Pyramid
Python
28
star
32

pyramid_rpc

RPC plugins for pyramid. XML-RPC, JSON-RPC, etc.
Python
27
star
33

translationstring

A library used for internationalization (i18n) duties related to translation.
Python
26
star
34

pyramid_layout

Pyramid add-on for managing UI layouts.
Python
24
star
35

virginia

Pyramid sample application for publishing filesystem content
Python
24
star
36

pastedeploy

provides code to load WSGI applications and servers from URIs
Python
23
star
37

pyramid_mako

Mako templating system bindings for the Pyramid web framework
Python
23
star
38

pyramid_exclog

Exception logging tween for Pyramid
Python
22
star
39

trypyramid.com

trypyramid.com marketing website
HTML
19
star
40

plaster

Application config settings abstraction layer.
Python
17
star
41

weberror

WebError Error reporting and interactive debugger
Python
15
star
42

pyramid_simpleform

Bindings to help integrate formencode with Pyramid.
Python
15
star
43

horus

User registration and login system for the Pyramid Web Framework.
Python
14
star
44

akhet

Python
14
star
45

pylons_sphinx_theme

Pylons Sphinx Theme
CSS
13
star
46

pyramid_registration

User registration utilities for Pyramid (nascent)
Python
13
star
47

pyramid_jqm

JQuery Mobile starter scaffolding for Pyramid
JavaScript
12
star
48

cartouche

Reusable user registration views for Pyramid apps.
Python
12
star
49

SQLAHelper

Python
11
star
50

pyramid_nacl_session

Encrypting, pickle-based cookie serializer using PyNaCl
Python
10
star
51

pyramid_routehelper

Pyramid Route and View Handler Helpers
Python
10
star
52

pyramid_chameleon

Chameleon template compiler for pyramid
Python
10
star
53

pyramid_who

Authentication policy for pyramid using repoze.who 2.0 API
Python
10
star
54

groundhog

Silly "microframework" based on Flask semantics written with Pyramid
Python
9
star
55

pyramid_ldap

LDAP authentication policy for Pyramid
Python
9
star
56

pyramid_handlers

Pyramid "handlers" emulate Pylons 1 "controllers"
Python
8
star
57

pyramid_ipython

IPython bindings for Pyramid's pshell.
Python
7
star
58

zodburi

Construct ZODB storage instances from URIs.
Python
7
star
59

plaster_pastedeploy

A PasteDeploy binding to the plaster configuration loader.
Python
7
star
60

pyramid_retry

An execution policy for pyramid that handles retryable errors.
Python
6
star
61

docs-style-guide

Documentation Style Guide for all projects under the Pylons Project
Python
6
star
62

pyramid_xmlrpc

XML-RPC helper code for the Pyramid web framework
Python
6
star
63

pyramid_errmail

Error mailing tween for Pyramid
Python
5
star
64

hybridauth

Example of declarative authorization using a hybrid of traversal and url dispatch
Python
5
star
65

miniconference

Miniconference repository
JavaScript
5
star
66

pyramid_traversalwrapper

Alternate traversal plugin for Pyramid which automates __parent__ and __name__
Python
5
star
67

pyramid_zcml

Package to externalize ZCML configuration for Pyramid
Python
4
star
68

pyramid_zodbconn

ZODB/Pyramid integration package
Python
4
star
69

sdidev

Buildout for Substance D SDI development
Python
3
star
70

substanced-cookiecutter

Cookiecutter template for SubstanceD
Python
3
star
71

repozitory

Simple versioning for Pyramid apps
Python
3
star
72

kai

Historic pylonshq website that ran with CouchDB / Pylons 1.0
Python
3
star
73

pyramid_chameleon_genshi

Chameleon-Genshi template rendering support for the Pyramid web framework
Python
3
star
74

pyramid-cookiecutter-zodb

[DEPRECATED - Please use https://github.com/pylons/pyramid-cookiecutter-starter instead] A Cookiecutter (project template) for creating a Pyramid project using ZODB for persistent storage, traversal for routing, and Chameleon for templating.
Python
3
star
75

pyramid_viewgroup

Pyramid package which provides "view groups" (like Zope3 content providers/viewlets)
Python
2
star
76

guillotine

Middleware for proper handling of HEAD requests.
Python
2
star
77

stateof

PyCon presentation work area
JavaScript
2
star
78

pylons-sphinx-themes

Sphinx themes for projects under the Pylons Project, but in a Python package instead of git submodule.
CSS
2
star
79

pylonsproject.org

pylonsproject.org marketing website
HTML
2
star
80

jslibs

Common JavaScript libraries for Pyramid projects
JavaScript
2
star
81

pyramid_skins

Templating framework for Pyramid.
Python
2
star
82

pyramid_formish

Bindings to the Formish form generation library for the Pyramid web framework.
Python
2
star
83

breckenridge

Breckenridge sprint info
1
star
84

pyramid_buildout

Sample Pyramid app which uses zc.buildout to manage dependencies
1
star
85

sdexternaledit

External Editor integration for Substance D
Python
1
star
86

sdnet_buildout

substanced.net software
CSS
1
star
87

pylons_sphinx_latesturl

Add a 'latest_url' key to the Sphinx template namespace for use in for a versioned document sets.
Python
1
star
88

pyramid_amon

Pyramid add-on for Amon application and system monitoring toolkit.
Python
1
star
89

pyramid_metatg

TurboGears2-like object dispatch for Pyramid (example)
Python
1
star
90

trypyramid.com-pages

Contains the pages output for trypyramid.com
1
star
91

QuickWiki

Pylons Web Framework QuickWiki tutorial app
Python
1
star
92

sweetpotatopie

YAML mappings for colander schemas
Python
1
star
93

hosted-services

The list of all hosted services for the Pylons Project
1
star
94

walkabout

Predicate-based component dispatch.
Python
1
star
95

pyramid-scaffold-theme

Scaffold theme for pyramid projects.
Python
1
star
96

pyramid_zodbsessions

A session factory for Pyramid which uses session data objects stored in ZODB
Python
1
star