What’s New In FormEncode 0 to 1.2.4¶
Contents
1.2.4¶
Fix packaging issue with i18n files (from Juliusz Gonera)
1.2.3¶
Code repository moved to BitBucket at ianb/formencode.
Allowed
formencode.validators.UnicodeStringto use different encoding of input and output, or no encoding/decoding at all.Fixes #2666139: DateValidator bug happening only in March under Windows in Germany :)
Don’t let
formencode.compound.Anyshortcut validation when it gets an empty value (this same change had already been made toformencode.compound.All).Really updated German translation
Fixes #2799713: force_defaults=False and <select> fields, regarding
formencode.htmlfill.render(). Thanks to w31rd0 for the bug report and patch to fix it.
1.2.2¶
Added keyword argument
force_defaultstoformencode.htmlfill.render(); when this is True (the default) this will uncheck checkboxes, unselect select boxes, etc., when a value is missing from the default dictionary.Updated German translation
1.2.1¶
Be more careful about
unicode(Invalid(...)), to make sure it always returns unicode.Fix broken
formencode.nationalzip code validators.In
formencode.nationalonly warn about the pycountry or TG requirement when creating validators that require them.Fix another
formencode.htmlfillerror due to a field with no explicit value.
1.2¶
Added
formencode.validators.IPAddress, validating IP addresses, from Leandro Lucarella.Added
formencode.api.Invalid.__unicode__()In
formencode.htmlfilluse a default encoding of utf8 when handling mixedstr/unicodecontent. Also do not modify<input type="image">tags (previouslysrcwould be overwritten, for no good reason).In
formencode.validators.Emailallow single-character domain names (like x.com).Make
formencode.validators.FieldsMatchgive a normalInvalidexception if you pass it a non-dictionary. Also treat all missing keys as the empty string (previously the first key was required and would raise KeyError).formencode.validators.Numberworks withinffloat values (before it would raise a OverflowError).The
twlocale has been renamed to the more standardzh_TW.Added Japanese and Turkish translations.
Fixed some outdated translations and errors in Spanish and Greek translations. Translations now managed with Babel.
1.1¶
Fixed the
is_empty()method informencode.validators.FieldStorageUploadConverter; previously it returned the opposite of the intended result.Added a parameter to
htmlfill.render():prefix_error. If this parameter is true (the default) then errors automatically go before the input field; if false then they go after the input field.Remove deprecated modules:
fields,formgen,htmlform,sqlformgen, andsqlschema.Added
formencode.htmlrename, which renames HTML inputs.In
formencode.htmlfill, non-string values are compared usefully (e.g., a select box with integer values).The validators
IntandNumberboth take min/max arguments (from Shannon Behrens).Validators based on
formencode.validators.FormValidatorwill not treat{}as an empty (unvalidated) value.Some adjustments to the URL validator.
formencode.compound.Alldoes not handle empty values, instead relying on sub-validators to check for emptiness.Fixed the
if_missingattribute informencode.foreach.ForEach; previously it would be the same list instance, so if you modified it then it would effect futureif_missingvalues (reported by Felix Schwarz).Added formatter to
formencode.htmlfill, so you can use<form:error name="field_name" formatter="ignore" />– this will cause the error to be swallowed, not shown to the user.Added
formencode.validators.XRIfor validation i-names, i-numbers, URLs, etc (as used in OpenID).Look in
/usr/share/localefor locale files, in addition to the normal locations.Quiet Python 2.6 deprecation warnings.
Fix
formencode.validators.URL, which was accepting illegal characters (like newlines) and did not accept http://domain:PORT/
1.0.1¶
chained_validatorswere removed from Schema somehow; now replaced and working.Put in missing
htmlfill.render(error_class=...)parameter (was documented and implemented, butrender()did not pass it through).
1.0¶
Added
formencode.schema.SimpleFormValidator, which wraps a simple function to make it a validator.Changed the use of
chained_validatorsin Schemas, so that all chained validators get run even when there are previous errors (to detect all the errors).While something like
Int.to_python()worked, other methods likeInt.message(...)didn’t work. Now it does.Added Italian, Finnish, and Norwegian translations.
0.9¶
Backward incompatible changes¶
The notion of “empty” has changed to include empty lists, dictionaries, and tuples. If you get one of these values passed into (or generated by) a validator with
not_empty=Trueyou can get exceptions where you didn’t previously.
Enhancements¶
Added support for Paste’s MultiDict dictionary as input to Schema.to_python, by converting it to a normal dict via MultiDict.mixed. Previously MultiDicts wouldn’t work with CompoundValidators (like ForEach)
Added encoding parameter to htmlfill, which will handle cases when mixed str and unicode objects are used (turning all str objects into unicode)
Include
formencode.validators.InternationalPhoneNumberfrom W-Mark Kubacki.validators.Inttakesminandmaxoptions (from Felix Schwarz).You can control the missing message (which by default is just “Missing Value”) using the message
"missing"in a validator (also from James Gardner).Added
validators.CADR(for IP addresses with an optional range) andvalidators.MACAddress(from Christoph Haas).
Bug Fixes¶
Be friendlier when loaded from a zip file (as with py2exe); previously only egg zip files would work.
Fixed bug in htmlfill when a document ends with no trailing text after the last tag.
Fix problem with HTMLParser’s default unescaping routing, which only understood a very limited number of entities in attribute values.
Fix problem with looking up A records for email addresses.
validators.Stringnow always returns strings. It also converts lists to comma-separated strings (no[...]), and can encode unicode if anencodingparameter is given. Empty values are handled better.validators.UnicodeStringproperly handles non-Unicode inputs.Make
validators.DateConverterserialize dates properly (from James Gardner).Minor fix to setup.py to make FormEncode more friendly with zc.buildout.
0.7.1¶
Set
if_missing=()onvalidators.Set, as a missing value usually means empty for this value.Fix for
Emailvalidator that searches A records in addition to MX records (from Jacob Smullyan).Fixes for the
eslocale.
0.7¶
Backward compatibility issue: Due to the addition of i18n (internationalization) to FormEncode, Invalid exceptions now have unicode messages. You may encounter unicode-related errors if you are mixing these messages with non-ASCII
strstrings.gettext-enabled branch merged in
from formencode.validators import *will import theInvalidexception now.Invalid().unpack_errors(encode_variables=True)now filters out None values (whichForEachcan produce even for keys with no errors).
0.6¶
String(min=1)impliesnot_empty(which seems more intuitive)Added
list_charanddict_chararguments toInvalid.unpack_errors(passed through tovariable_encode)Added a
use_datetimeoption toTimeValidator, which will cause it to usedatetime.timeobjects instead of tuples. It was previously able to consume but not produce these objects.Added
<form:iferror name="not field_name">when you want to include text only when a field has no errors.There was a problem installing 0.5.1 on Windows with Python 2.5, now resolved.
0.5.1¶
Fixed compound validators and
not_empty(was breaking SQLObject’s PickleCol)
0.5¶
Added
htmlfill.default_formatter_dict, and you can poke new formatters in there to effective register them.Added an
escapenlformatter (nl=newline) that escapes HTML and turns newlines into<br>.When
not_empty=False, empty is assumed to be allowed. ThusInt().to_python(None)will now returnNone.
0.4¶
Fixed up all the documentation.
Validator
__doc__attributes will include some automatically-appended information about all the message strings that validator uses.Deprecated
formencode.htmlformmodule, because it is dumb.Added an
.all_messages()method to all validators, primarily intended to be used for documentation purposes.Changed preferred name of
StringBooleantoStringBool(to go withboolandvalidators.Bool). Old alias still available.Added
today_or_afteroption tovalidators.DateValidator.Added a
validators.FileUploadKeepervalidator for helping with file uploads in failed forms. It still requires some annoying fiddling to make work, though, since file upload fields are so weird.Added
text_as_defaultoption to htmlfill. This treats all<input type="something-weird">elements as text fields. WHAT-WG adds weird input types, which can usually be usefully treated as text fields.Make all validators accept empty values if
not_emptyis False (the default). “Empty” means""orNone, and will generally be converted None.Added
accept_pythonboolean to allFancyValidatorvalidators (which is most validators). This is a fixed version of the brokenvalidate_pythonboolean added in 0.3. Also, it defaults to true, which means that all validators will not validate during.from_python()calls by default.Added
htmlfill.render(form, defaults, errors)for easier rendering of forms.Errors automatically inserted by
htmlfillwill go at the top of the form if there’s no field associated with the error (raised an error in 0.3).Added
formencode.sqlschemafor wrapping SQLObject classes/instances. See the docstring for more.Added
ignore_key_missingtoSchemaobjects, which ignore missing keys (where fields are present) when noif_missingis provided for the field.Renamed
validators.StateProvince.extraStatestoextra_states, to normalize style.
Bugfixes¶
When checking destinations,
validators.URLnow allows redirect codes, and catches socket errors and turns them into proper errors.Fix typo in
htmlfillMade URL and email regular expressions a little more lax/correct.
A bunch of fixes to
validators.SignedString, which apparently was completely broken.
0.3¶
Allow errors to be inserted automatically into a form when using
formencode.htmlfill, when a<form:error>tag isn’t found for an error.Added
if_key_missingattribute toschema.Schema, which will fill in any keys that are missing and pass them to the validator.FancyValidatorhas changed, addingif_invalid_pythonandvalidate_pythonoptions (which also apply to all subclasses). Alsoif_emptyonly applies toto_pythonconversions.FancyValidatornow has astripoption, which if true and if input is a string, will strip whitespace from the string.Allow chained validators to validate otherwise-invalid forms, if they define a
validate_partialmethod. The credit card validator does this.Handle
FieldStorageinput (from file uploads); added aformencode.fieldstoragemodule to wrap those instances in something a bit nicer. Addedvalidators.FieldStorageUploadConverterto make this conversion.Added
StringBooleanconverter, which converts strings like"true"to Python booleans.
Bugfixes¶
A couple fixes to
DateConverter,FieldsMatch,StringBoolean,CreditCardValidator.Added missing
Validator.assert_stringmethod.formencode.htmlfill_schemabuilderhandles checkboxes better.Be a little more careful about how
Invalidexceptions are created (catch some errors sooner).Improved handling of non-string input in
htmlfill.
Experiments¶
Some experimental work in
formencode.formgen. Experimental, I say!Added an experimental
formencode.contextmodule for dynamically-scoped variables.