Package: deform
IntroductionUse casesInstallationExampleStatusProjects using DeformCommunity and links2.0.15 (2020-12-10)Features and FixesDeprecationsDocumentation2.0.14 (2020-08-26)2.0.13 (2020-08-25)2.0.12 (2020-08-23)2.0.11 (2020-08-21)2.0.10 (2020-07-03)2.0.9 (2020-07-03)2.0.8 (2019-10-07)2.0.7 (2018-11-14)2.0.6 (2018-08-29)2.0.5 (2018-02-20)2.0.4 (2017-02-11)2.0.3 (2016-11-19)2.0.2 (2016-11-14)2.0.1 (2016-10-25)2.0 (2016-10-23)2.0b3 (2016-10-22)2.0b2 (2016-10-22)2.0b1 (2016-10-22)2.0a2 (2013-10-18)2.0a1 (2013-10-05)IntroductionDeform 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 itemsand a few othercomplex
use casesare supported out of the box.Deform integrates with thePyramid web frameworkand several other web frameworks. Deform comes withChameleon templatesandBootstrap 3styling. Under the hood,Colander schemasare used for serialization and
validation. ThePeppercornlibrary
maps HTTP form submissions to nested structure.Although Deform uses Chameleon templates internally, you can embed rendered
Deform forms into any template language.Use casesDeform is ideal for complex server-side generated forms. Potential use cases
include:Complex data entry formsAdministrative interfacesPython based websites with high amount of data manipulation formsWebsites where additional front end framework is not neededInstallationInstall usingpip and Python package installation best practices:pip install deformExampleSee all widget examples. Below is a sample
form loop using thePyramidweb framework.Example code:"""Self-contained Deform demo example."""from__future__importprint_functionfrompyramid.configimportConfiguratorfrompyramid.sessionimportUnencryptedCookieSessionFactoryConfigfrompyramid.httpexceptionsimportHTTPFoundimportcolanderimportdeformclassExampleSchema(deform.schema.CSRFSchema):name=colander.SchemaNode(colander.String(),title="Name")age=colander.SchemaNode(colander.Int(),default=18,title="Age",description="Your age in years")defmini_example(request):"""Sample Deform form with validation."""schema=ExampleSchema().bind(request=request)# Create a styled button with some extra Bootstrap 3 CSS classesprocess_btn=deform.form.Button(name='process',title="Process")form=deform.form.Form(schema,buttons=(process_btn,))# User submitted this formifrequest.method=="POST":if'process'inrequest.POST:try:appstruct=form.validate(request.POST.items())# Save form data from appstructprint("Your name:",appstruct["name"])print("Your age:",appstruct["age"])# Thank user and take him/her to the next pagerequest.session.flash('Thank you for the submission.')# Redirect to the page shows after succesful form submissionreturnHTTPFound("/")exceptdeform.exception.ValidationFailurease:# Render a form version where errors are visible next to the fields,# and the submitted values are posted backrendered_form=e.render()else:# Render a form with initial default valuesrendered_form=form.render()return{# This is just rendered HTML in a string# and can be embedded in any template language"rendered_form":rendered_form,}defmain(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")returnconfig.make_wsgi_app()This example is indeformdemo repository. Run the example with pserve:pserve mini.ini --reloadStatusThis 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 DeformWebsaunaKottiSubstance DCommunity and linksWidget examplesPyPIIssue trackerWidget examples repoDocumentationSupport2.0.15 (2020-12-10)Features and FixesAdd support of Python 3.8 and 3.9.Added a new widgetSelectizeWidgetbased on the jQuery pluginselectize.js. [stevepiercy]https://github.com/Pylons/deform/issues/260Improved handling of thereadonlyHTML attribute in certain widgets. ThereadonlyHTML form control attribute makes the element not mutable,
meaning the user cannot edit the control. When"readonly": "readonly"is
one of the items in a dict passed into theattributesoption when
creating a widget, the rendered widget both prevents the user from changing
the value, and if the form does not pass validation after submitted then the
field value will be displayed.readonlyis supported by most form controls, but not all. Deform adds
some logic to add read-only support for a few of those form controls, as
described below.CheckboxWidgetandCheckboxChoiceWidgetDue to the nature of how checkbox values are processed, thereadonlyattribute has no effect.
To achieve a read-only behavior, pass inattributes={"onclick":"returnfalse;"}.
This will render as an inline JavaScriptonclick="returnfalse;"for
each checkbox item.MoneyInputWidgetThe provided value will be displayed in the input and be not editable.RadioChoiceWidgetFor the selected value it will render an attribute in the HTML asreadonly="readonly", and for all other values asdisabled="disabled".SelectWidgetFor selection of single options only, the selected value will render an
attribute in the HTML asreadonly="readonly", and for all other values
asdisabled="disabled".
Multiple selections, set by themultiple=Trueoption, do not support
thereadonlyattribute on the<select>element.
For multiple selections, use theSelectizeWidget.SelectizeWidgetFor both single and multiple selections, the selected value or values will
be rendered as selected, and the others will not be selectable.
Selectize uses JavaScript to “lock” the form control.TextAreaWidgetThe provided value will be displayed in the input and be not editable.TextInputWidgetThe provided value will be displayed in the input and be not editable.[stevepiercy]https://github.com/Pylons/deform/issues/260Optionally bypass the resource registry and specify a resource as a dict
where its keys are the type of asset ("js"or"css") and its values
are either a string or a list of strings of paths to assets on disk.
[tdamsma]https://github.com/Pylons/deform/issues/485Conditionally loadjquery.maskedinputif and only ifmaskoption is
provided. [tisdall, stevepiercy]https://github.com/Pylons/deform/pull/487Changed dateparts widget to usetype="number"instead of defaulttext. [stevepiercy]https://github.com/Pylons/deform/issues/442Clarify that a sequence type (list, tuple, or x/range) is required for values
passed into aSelectWidgetorRadioChoiceWidget. [stevepiercy]https://github.com/Pylons/deform/issues/385Switch from using nosetests to pytest as the test runner, as nosetests is no
longer maintained. [stevepiercy]https://github.com/Pylons/deform/pull/497https://github.com/Pylons/deform/pull/498Switch from Travis-CI and Appveyor to GitHub Actions, due to Travis-CI
changing its plans to be ineffective for the Pylons Project. [stevepiercy]https://github.com/Pylons/deform/pull/492https://github.com/Pylons/deform/pull/495Add Docker containerization of Deform and deformdemo as an option for running
tests, and improve related documentation. [sydoluciani]https://github.com/Pylons/deform/pull/493https://github.com/Pylons/deform/pull/494DeprecationsDrop support of Python 3.5.Select2Widgetis now deprecated and will be removed in Deform 3.0.0
because its jQuery plugin Select2 removed a lock feature in v4.0.0 and its
future development is uncertain. [stevepiercy]https://github.com/Pylons/deform/issues/260DocumentationAdd documentation of arbitrary HTML5 attributes for all widgets.
[stevepiercy]https://github.com/Pylons/deform/issues/430Add usage documentation ofDate,DateTime, andTimewidgets. Add
documentation reference to complex data loading, changing widgets, or
validating data to Colander. [stevepiercy]https://github.com/Pylons/deform/pull/4662.0.14 (2020-08-26)Field.validate() now raisesValidationFailureupon peppercorn parse
failure.
Seehttps://github.com/Pylons/deform/pull/242Bump maskMoney.js to 3.1.1 and use minified version.https://github.com/Pylons/deform/issues/4122.0.13 (2020-08-25)richtext.pt: The contents of theRichTextWidget’s <textarea>
was not HTML-escaped, but now it is.Note that unescaped content is still rendered ifdelayed_loadis
enabled.  Now, however, to avoid rendering unescaped non-validated
user input,delayed_loadis ignored when redisplaying a field
containing an error.
Seehttps://github.com/Pylons/deform/pull/204This time,reallyupdate select2 widget to version 4.0.13.
Seehttps://github.com/Pylons/deform/pull/4592.0.12 (2020-08-23)Update select2 widget to version 4.0.13.
Seehttps://github.com/Pylons/deform/pull/441Add thestructurekeyword to the autocomplete template’s options to stop
its encoding.
Seehttps://github.com/Pylons/deform/pull/445Use the local HTML element for change event when removing/adding to DOM.
Seehttps://github.com/Pylons/deform/pull/331Fix deprecation warning when importing the modulefield.pywhile testing
with pytest.
Seehttps://github.com/Pylons/deform/pull/419Fix a bug that was introduced in 2.0.11 that made it such that thefocusparameter on forms did not honor theoffvalue forcheckboxChoiceandradioChoicewidgets.
Seehttps://github.com/Pylons/deform/pull/453Remove the unused variablenamematchfrom deform.js.
Seehttps://github.com/Pylons/deform/pull/454Add i18n domain and Bootstrap styles to templatereadonly/password.pt.
Seehttps://github.com/Pylons/deform/pull/2372.0.11 (2020-08-21)Drop support of Python 3.4.Changed the implementation of input autofocus from JavaScript to an HTML5
input attribute.Forms now have an optionalfocusparameter (onoroff) and fields
have an optionalautofocusparameter.Iffocusison, and at least one field has anautofocusschema parameter set toon, the first of these fields will
receive focus on page load.Iffocusisonor omitted, and no field has anautofocusschema parameter set toon, the first input of
the first form on the page will receive focus on page load.Iffocusisoff, no focusing will be done.Default:on.
(This is unchanged from the JavaScript implementation.)Seehttps://github.com/Pylons/deform/pull/365/Replace the flake8-isort plugin with plain old isort.
Seehttps://github.com/Pylons/deform/pull/427Improved the script that launches Selenium webdriver to clean up the locale
directory after completing a run of functional tests so that its files do not
get committed by accident. We also enforce coding style and add a formatter,
and improved the contributing documentation.
Seehttps://github.com/Pylons/deform/pull/428Updated Bootstrap to 3.4.1.2.0.10 (2020-07-03)Correct release date.2.0.9 (2020-07-03)Added CSRF test to pass coverage on schema.py.
Seehttps://github.com/Pylons/deform/pull/403Modified the DateTimeInputWidget to use HTML5 date/time input types on
browsers that support it.
Seehttps://github.com/Pylons/deform/pull/406Add new translations for Swahili (sw_KE) locale.
Seehttps://github.com/Pylons/deform/pull/409Add boolean HTML attributes per Chameleon 3.8.0.All checkboxes, radios, and selects that use boolean HTML attributes
(selected, checked, etc.) previously usedliteral_falseand would drop anyFalsevalue from rendering as an HTML attribute. In Chameleon 3.8.0,literal_falseis removed and must instead useboolean_attributesto set
defaults.Seehttps://github.com/Pylons/deform/issues/4172.0.8 (2019-10-07)Add HTML5 attributes to buttons.
Seehttps://github.com/Pylons/deform/pull/3902.0.7 (2018-11-14)Addtagsoption support toSelect2WidgetSeehttps://github.com/Pylons/deform/pull/373Change Python 3.7 to use stable version, 3.8-dev as allowed failure, in
Travis.
Seehttps://github.com/Pylons/deform/pull/377Update Bootstrap to 3.3.7.Add support for HTML5 attributes (e.g. including placeholder and maxlength)
Seehttps://github.com/Pylons/deform/pull/3452.0.6 (2018-08-29)Drop Python 3.3 support.
Seehttps://github.com/Pylons/deform/pull/371Add support to Python 3.7.Make date_submit and time_submit optional in DateTimeInputWidget
Seehttps://github.com/Pylons/deform/pull/369Remove pinning of iso8601 to 0.1.11
Seehttps://github.com/Pylons/deform/pull/364i18n cleanuphttps://github.com/Pylons/deform/pull/367andhttps://github.com/Pylons/deform/pull/3682.0.5 (2018-02-20)i18n cleanuphttps://github.com/Pylons/deform/pull/332andhttps://github.com/Pylons/deform/pull/363Fix bug in_FieldStorageunder Python 3.x (issues #339 and #357).Declare Python 3.6 compatibility and enable tests against Python 3.6 (all tests pass with no changes).Closes #333: MANIFEST.in including docs, licenses and text files.Addlinkbutton type Seehttps://github.com/Pylons/deform/issues/166Add traditional chinese localization2.0.4 (2017-02-11)Added ability to pass a translator function todeform.renderer.configure_zpt_renderer2.0.3 (2016-11-19)Added accordions to MappingWidget:https://deformdemo.pylonsproject.org/mapping_accordion/Added CSS classdeform-form-buttonsto style form button group:https://github.com/Pylons/deform/pull/308Add more options toTextAreaCSVWidget:https://github.com/Pylons/deform/pull/309Always render an item with a default CSS class:https://github.com/Pylons/deform/pull/306Updated pickdate.js library used for the date picker:https://github.com/Pylons/deform/pull/248Widget Selenium test suite runs both under Python 2 and 3.
Lots of Selenium testing headache fixed with some implicit wait support.NoteCurrently Python 3 file upload widget may have compatibility issues.
Please seedeformdemo/test.pyfor details.2.0.2 (2016-11-14)Fix regression of<select>widget default values not honouredUpdated Select2 widget JavaScript2.0.1 (2016-10-25)Drop support for Python 2.6.Documentation reorganization and clean up to conform with Pylons Project
projects.Fix select and select2 widget templates failing on Python 3.x2.0 (2016-10-23)Release polish2.0b3 (2016-10-22)Update demos and add standalone mini example2.0b2 (2016-10-22)Fix README on PyPI2.0b1 (2016-10-22)Updated bootstrap to 3.3.6.Fix dateparts.pt and datetimeinput.pt for changes in bootstrap v3.0.3.
(The culprit is boostrap commit853b69f.)Makedateinputwork again by using the fixed name “date” as expected
by the pstruct schema.  Seehttps://github.com/Pylons/deform/pull/221.ChangedISO8601_REGEXimport to match change in colanderAdd support for Python 3.4, PyPy3.RaiseInvalidrather than other errors when deserializing broken
or malicious pstructs with invalid types.  Seehttps://github.com/Pylons/deform/pull/203Read a time widget.Fix a bug in the DateInputWidget.  Seehttps://github.com/Pylons/deform/pull/192.Ensured thatNonewould not show up as a css class name in rendered
template output.  Seehttps://github.com/Pylons/deform/pull/191we now use dashed-names (e.g.deform-seq).  A full list of changes is
below:Old                               New

deformClosebutton                 deform-closebutton
deformFileupload                  deform-file-upload
deformFormFieldset                deform-form-fieldset
deformInsertBefore                deform-insert-before
deformOrderbutton                 deform-orderbutton
deformProto                       deform-proto
deformReplaces                    deform-replaces
deformSeq                         deform-seq
deformSeqAdd                      deform-seq-add
deformSeqContainer                deform-seq-container
deformSeqItem                     deform-seq-item
deformSet-item                    deform-set-item
errorMsg                          error-msg
errorMsgLbl                       error-msg-lblFixed handling of buttons in nested sequences.
Seehttps://github.com/Pylons/deform/issues/197Upload widget is themed like Bootstraphttps://github.com/Pylons/deform/pull/280Select widget handles the mixture of strings and intshttps://github.com/Pylons/deform/pull/300/andhttps://github.com/Pylons/deform/pull/299Have the button css_class override the default button class. This is
backwards-incompatible and will require users of css_class to add a
btn-default/btn-primary class to the css_class.Simplified Chinese translationhttps://github.com/Pylons/deform/pull/274Don’t cause unnecessary JavaScript calls on page loadhttps://github.com/Pylons/deform/pull/267/Allow override Button Bootstap CSS styleshttps://github.com/Pylons/deform/pull/2512.0a2 (2013-10-18)PasswordWidgetandCheckedPasswordWidgethave grown an additional
argument/attribute namedredisplay, which controls what happens on a
validation failure of a form involving such a field.  IfredisplayisTrue(the default), the password will be re-rendered into the form when
the form is re-rendered after validation failure.  IfredisplayisFalse, the password will not be re-rendered into the form.  The default
isFalse, which means that, as of this release, passwords will not
be redisplayed; this changes the default behavior wrt previous releases.
Values typed into password fields are not redisplayed by default during
validation failure, as a security measure (the value winds up in browser
history).  UsePasswordWidget(redisplay=True)orCheckedPasswordWidget(redisplay=True)to make these widgets redisplay
passwords on validation failures, matching the old behavior.When using the default Chameleon template renderer, template names can now
be “asset specifications” e.g.mypackage:subdir1/subdir2/mytemplate.ptinstead of extensionless paths relative to a search path.  When
template names are specified as asset specifications, thepkg_resources.resource_filenameAPI is used to dereference them
into an actual file path.2.0a1 (2013-10-05)This is an alpha release of Deform v2.  Deform v2 is backwards incompatible
with Deform v1.  It requires the use of Twitter Bootstrap v3, whereas
deform v1 did not require Bootstrap.A demonstration site that shows Deform 2 in action exists athttps://deformdemo.pylonsproject.org.Both Deform 1 and Deform 2 will be maintained going forward.  If you wish
to continue using Deform 1, because you cannot upgrade, or cannot depend on
Bootstrap 3, please pin your deform distribution requirement to
something below 2.0a1, e.g.deform<=1.999.This first alpha release is missing formal documentation updates.  Apologies,
we needed to get a release out onto PyPI, as not having one is holding back
the development of a number of platforms and applications that depend on the
changes in v2+.  Documentation updates will be forthcoming over the lifetime
of future alpha/beta releases.  However, below is a list of known issues that
need to be addressed to make a final release of Deform 2, as well as
information about new features, and migration notes.  You may also be
able to make use of the demo site athttps://deformdemo.pylonsproject.orgto
divine how things have changed, and what CSS and JavaScript resources you’ll
need to include in your pages to make use of this release.TODOdocsdecide how to explain form.css (include in requirements or?)horizontal/inline forms + structural thingsassets for templates: deform should provide a tool to resolve that?placeholder support for all textual inputs (and required/maxlength
see alsohttps://github.com/Pylons/deform/pull/116)display help-blocks for readonly fields?maybe readonly should be a property of the schema, not the widget.consider whether “style”/”css_class” on multi-input widgets should apply to
a container or each element.audit use of e.g. string:${css_class} so we don’t see unexpected class=”None”
in widget rendering output.some sort of test for mapping_item input_prepend/input_appendCurrently description shows up as both tooltip of label and as help-block.
Maybe make these two things separate or at least don’t show them both using
the same value.normalize CSS class names to deform-foo rather than deformFoosequence_of_sequences: js that processes close/order buttons has to
be less promiscuous (it uses e.g. “find”); symptom: buttons
appear/disappear, act on the wrong element, etc… ugh 2013/10/05
cannot replicate, but still believe there may be an issue, but
maybe iElectric fixed itNICE TO HAVEstructural widget (mapping_item.pt) - do we need that or not or what? +
add a demoprepend/append t.bootstrap stuffhttps://github.com/Pylons/deform/pull/116#issuecomment-23210460group demos by widget typehandle ajax demo more UX friendlyPut drag handles in panel headers:https://github.com/Pylons/deform/issues/180NEW FEATURES:input_prepend/input_append in mapping_item widget.field.parentfield.get_rootinline attr of checkboxchoice and radiochoice widgets (seehttps://github.com/Pylons/deform/pull/182)https://deformdemo.pylonsproject.org/MIGRATION NOTES:removed deprecatedheight, width, skin, themeparameters from RichTextWidget
(use “options” instead)removed deprecatedrender_initial_itemfrom SequenceWidgetremoved deprecated deform.Set (use colander.Set instead)DateInputWidget renamed parameterdateFormattoformat(dateFormat
now unsupported).DateTimeInputWidget now renders as two fields: one for a date and one
for a time, using pickadate.We no longer bother trying to use the native datetimeinput widget on any
browser, because the support is so spotty.DateTimeInputWidget takes two options now: date_options and time_options
instead of a single options dictionary.  The options are pickadate
date/time options respectively.It is no longer possible to do DateTimeWidget().options[‘a’] = ‘foo’
or DateTimeWidget().date_options[‘a’] = ‘foo’.  If you need to change
options imperatively, set the entire .options/.date_options dictionary.merged TypeaheadInputWidget to AutocompleteInputWidget (removed delay
parameter)AutocompleteInputWidget now accepts string type for “values”widgets no longer accepts “size” (instead use style=”width: x”), except
SelectWidget (it means the size of the dropdown)get_widget_resources now returns asset specifications rather than
deform-static-relative pathsdeform 2.0 requires users to manually load TB 3.0 and jquery 2.0required labels no longer insert an asterisk inside a <span class=”req”>
inside themselves.  instead the label element has a required class
if the field is required; use form.css to display this as an asterisk.min_length of AutocompleteInputWidget now defaults to 1 (was 2)