Package: colander
ColanderAn extensible package which can be used to:deserialize and validate a data structure composed of strings,
mappings, and lists.serialize an arbitrary data structure to a data structure composed
of strings, mappings, and lists.It is tested on Python 3.7, 3.8, 3.9, 3.10, and 3.11, and PyPy 3.8.Please seehttps://docs.pylonsproject.org/projects/colander/en/latest/for documentation.Seehttps://github.com/Pylons/colanderfor in-development version.2.0 (2022-01-02)Drop support for Python 2.7, 3.4, 3.5, 3.6.Add support for Python 3.10, 3.11.[breaking]If abytesobject is serialized by aStringschema
node with theencodingparameter specified, it will be passed through
directly tostrfirst, causing it to come out with ab''prefix. In
order to serialize it properly, it should be decoded to a string first.
Previously, when theencodingparameter was specified it would be decoded
and re-encoded, effectively passing it through untouched, despite not being a
string type.Add a newcolander.DataURLvalidator.
Seehttps://github.com/Pylons/colander/pull/348Add IDN support tocolander.url.
Seehttps://github.com/Pylons/colander/pull/352colander.Allnow supportscolander.Invalid.msgbeingNoneor a
list, otherwisecolander.Invalid.asdictcrashes withTypeError: sequence item 1: expected str instance, NoneType found.
Seehttps://github.com/Pylons/colander/pull/333andhttps://github.com/Pylons/colander/issues/194Fixed an issue withcolander.Mappingandcolander.Sequencewhere adefaultvalue ofdropcaused missing values to be dropped
during deserialization. (Onlymissingvalues should affect
deserialization, and onlydefaultvalues should affect serialization.)
Added many new test cases forMappingSchemaandSequenceSchema.
Seehttps://github.com/Pylons/colander/pull/264Remove the dependency onsetuptoolsfor resolving pkg_resources-style
importable paths incolander.GlobalObject.Refresh localization files with Babel 2.11.1.8.3 (2020-11-28)Add support for Python 3.9.Fix handling ofinsert_beforeon deferred nodes so that it inserts the
new node before the specified node instead of always appending to the end ofnode.childrenafter binding.1.8.2 (2020-08-07)Fix the broken wheels in 1.8.1 and 1.8.0 to include the locale data.sigh1.8.1 (2020-08-06)Fix the broken wheels in 1.8.0 to include the locale data.1.8.0 (2020-08-05)Drop support for Python 3.4.Add support for Python 3.7 and 3.8.Fix deserializer onDateandDateTimefields to correctly catchValueErrorandTypeErrorexception, which can arise when using custom
formats on the field. Instead of allowing these exceptions to propagate,
replace then with anInvalidexception instead.
Seehttps://github.com/Pylons/colander/pull/3381.7.0 (2019-02-01)The URL validator regex has been updated to no longer be vulnerable to a
catastrophic backtracking that would have led to an infinite loop. Seehttps://github.com/Pylons/colander/pull/323andhttps://github.com/Pylons/colander/issues/290. With thanks to Przemek
(https://github.com/p-m-k).This does change the behaviour of the URL validator and it no longer supportsfile://URI scheme (https://tools.ietf.org/html/rfc8089). Users that
wish to validatefile://URI’s should change their validator to usecolander.file_uriinstead.It has also dropped support for alternate schemes outside of http/ftp (and
their secure equivelants). Please let us know if we need to relax this
requirement.CVE-ID: CVE-2017-18361The Email validator has been updated to use the same regular expression that
is used by the WhatWG HTML specification, thereby increasing the email
addresses that will validate correctly from web forms submitted. Seehttps://github.com/Pylons/colander/pull/324andhttps://github.com/Pylons/colander/issues/283Number once again will allow you to serialize None to colander.null, this
reverts an accidental revert. Seehttps://github.com/Pylons/colander/issues/204#issuecomment-459556100Integer SchemaType now supports an optionalstrictmode that will
validate that the number is an integer, rather than silently accepting floats
and truncating. Seehttps://github.com/Pylons/colander/pull/322andhttps://github.com/Pylons/colander/issues/2921.6.0 (2019-01-31)Support custom format strings onDateTimeandDatefields.
Seehttps://github.com/Pylons/colander/pull/318Support sub-second precision onTimefields if provided.
Seehttps://github.com/Pylons/colander/pull/319Format Python code ofcolanderto conform to the PEP 8 style guide.
Add some linters (flake8,blackand other) intotox.ini.
Seehttps://github.com/Pylons/colander/pull/3201.5.1 (2018-09-10)Support deserializingcolander.dropandcolander.required.
Seehttps://github.com/Pylons/colander/pull/3041.5.0 (2018-09-07)Drop Python 3.3 support. Add PyPy3 and Python 3.7 as allowed failures.
Seehttps://github.com/Pylons/colander/pull/309Fix email validation to not allow all ASCII characters between + and /.
This prevents email addresses like ‘foo1,foo2@bar.baz’ from being validated,
which would be handled as multiple email addresses by subsequent tools.
Seehttps://github.com/Pylons/colander/pull/315Add support forenum.Enumobjects.
Seehttps://github.com/Pylons/colander/pull/305Recompiled language translations and updateddeandellocales.
Seehttps://github.com/Pylons/colander/pull/284andhttps://github.com/Pylons/colander/pull/3141.4.0 (2017-07-31)Remove thecolander.iso8601backward-compatibility module, broken
by recent updates to the actualiso8601package which backed it.
Downstream libraries can just mechanically adjust imports to useiso8601.iso8601instead ofcolander.iso8601.
Seehttps://github.com/Pylons/colander/pull/2961.3.3 (2017-04-25)Add “zh_Hant”, traditional chinese translations, and rename simplified
chinese from “zh” to “zh_Hans”.
Seehttps://github.com/Pylons/colander/pull/285Improve serialization of class objects usingcolander.GlobalObject.
Seehttps://github.com/Pylons/colander/pull/2881.3.2 (2017-01-31)Python 3.6 support.Allow deferred schema nodes.
Seehttps://github.com/Pylons/colander/pull/280Fix an issue when using a node multiple times in a schema by cloning it.
Seehttps://github.com/Pylons/colander/issues/279Fix a regression that brokeSequenceSchema.clone.
Seehttps://github.com/Pylons/colander/pull/275Update german translations.
Seehttps://github.com/Pylons/colander/pull/273Recompile language files.
Seehttps://github.com/Pylons/colander/pull/2701.3.1 (2016-05-23)1.3 was released without updating the changelog. This release fixes that.1.3 (2016-05-23)Drop Python 2.6 and PyPy3 from the test suite. They are no longer
supported. Seehttps://github.com/Pylons/colander/pull/263colander.Stringschema type now supports an optional keyword argumentallow_emptywhich, when True, deserializes an empty string to an
empty string. When False (default), an empty string deserializes tocolander.null. This allows for a node to be explicitly required, but
allow an empty (‘’) value to be provided.https://github.com/Pylons/colander/pull/199Addseparatorparameter tocolander.Invalid.asdict(for backward compatibility, default is ‘; ‘).
Seehttps://github.com/Pylons/colander/pull/253Fixed an issue withSchemaNode.clonewhere it would fail when
cloning an instance ofcolander.SequenceSchemadue to initializing
the schema without any children, violating some checks.
Seehttps://github.com/Pylons/colander/pull/2121.2 (2016-01-18)FeaturesAdd new exceptionUnsupportedFields. Used to pass to the caller a list
of extra fields detected in a cstruct during deserialize.
Seehttps://github.com/Pylons/colander/pull/241Adddropfunctionality toSequencetype.
Seehttps://github.com/Pylons/colander/pull/225Bug FixesSchemaNodewill no longer assume the first argument to the constructor
is the schema type. This allows it to properly fallback to using theschema_typeclass attribute on subclasses even when using the
imperative API to pass options to the constructor.Fix a bug in whichMappingSchema,SequenceSchemaandTupleSchemawould always treat the first arg as the schema type. This
meant that it would fail if passed only nodes to the constructor despite
the default type being implied by the name. It is now possible to doMappingSchema(child1, child2,...)instead ofMappingSchema(Mapping(),child1, child2).TranslationsAdded Finnish translations:fiSeehttps://github.com/Pylons/colander/pull/2431.1 (2016-01-15)PlatformAdd explicit support for Python 3.4, Python 3.5 and PyPy3.FeaturesAddmin_errandmax_errarguments toLength, allowing
customization of its error messages.Addcolander.Anyvalidator: succeeds if at least one of its
subvalidators succeeded.Allow localization of error messages returned bycolander.Invalid.asdictby adding an optionaltranslatecallable argument.Add amissing_msgargument toSchemaNode, allowing customization
of the error message used when the node is required and missing.AddNoneOfvalidator which succeeds if the value is none of the choices.Addnormalizeoption toDecimal, stripping the rightmost
trailing zeros.Bug FixesFix an issue where theflatten()method produces an invalid name
(ex: “answer.0.”) for the typeSequence.  Seehttps://github.com/Pylons/colander/issues/179Fixed issue withStringnot being properly encoded when non-string
values were passed intoserialize()See#235titlewas being overwritten when made a child through defining a schema
as a class. Seehttps://github.com/Pylons/colander/pull/239TranslationsAdded new translations:elUpdated translations:fr,de,ja1.0 (2014-11-26)Backwards IncompatibilitiesSchemaNode.deserializewill now raise anUnboundDeferredErrorif the node has an unbound deferred
validator.  Previously, deferred validators were silently ignored.
Seehttps://github.com/Pylons/colander/issues/47Bug FixesRemoved forkediso8601and change to dependency on PyPIiso8601(due to float rounding bug on microsecond portion when parsing
iso8601 datetime string).  Left aniso8601.pystub for backwards
compatibility.Time of “00:00” no longer givescolander.Invalid.Un-break wrapping of callable instances ascolander.deferred.
Seehttps://github.com/Pylons/colander/issues/141.Set the max length TLD to 22 inEmailvalidator based on the
current list of valid TLDs.
Seehttps://github.com/Pylons/colander/issues/159Fix an issue wheredropwas not recognized as a default and was
returning thedropinstance instead of omitting the value.https://github.com/Pylons/colander/issues/139Fix an issue where theSchemaNode.titlewas clobbered by thenamewhen defined as a class attribute.
Seehttps://github.com/Pylons/colander/pull/183andhttps://github.com/Pylons/colander/pull/185TranslationsUpdated translations:fr,de,ja1.0b1 (2013-09-01)Bug FixesIn 1.0a1, there was a change merged fromhttps://github.com/Pylons/colander/pull/73which made it possible to supplyNoneas thedefaultvalue for a String type, and upon serialization,
the value would be rendered ascolander.nullif the default were used.
This confused people who were actually supplying the valueNoneas a
default when the associated appstruct had no value, so the change has been
reverted.  When you supplyNoneas thedefaultargument to a String,
the rendered serialize() value will again be'None'.  Sorry.Normalizecolander.Functionargumentmessageto bemsg. This now
matches other APIs within Colander. Themessageargument is now
deprecated and a warning will be emitted.https://github.com/Pylons/colander/issues/31https://github.com/Pylons/colander/issues/64iso8601.py:  ConvertValueError(raised bydatetime) intoParseErrorrinparse_date, so that the validation machinery
upstream handles it properly.iso8601.py:  Correctly parse datetimes with a timezone of Z even
when the default_timezone is set. These previously had the default
timezone.colander.Stringschema type now raisescolander.Invalidwhen trying
to deserialize a non-string item.
Seehttps://github.com/Pylons/colander/issues/100FeaturesAddcolander.Listtype, modeled ondeform.List:  this type
preserves ordering, and allows duplicates.It is now possible to use the valuecolander.dropas thedefaultvalue for items that are subitems of a mapping.  Ifcolander.dropis used
as thedefaultfor a subnode of a mapping schema, and the mapping
appstruct being serialized does not have a value for that schema node, the
value will be omitted from the serialized mapping.  For instance, the
following script, when run would not raise an assertion error:class What(colander.MappingSchema):
  thing = colander.SchemaNode(colander.String(), default=colander.drop)

result = What().serialize({}) # no "thing" in mapping
assert result == {}Thetypof aSchemaNodecan optionally be pased in as a keyword
argument. Seehttps://github.com/Pylons/colander/issues/90Allow interpolation ofmissing_msgwith propertiestitleandname1.0a5 (2013-05-31)Fix bug introduced by supporting spec-mandated truncations of ISO-8601
timezones.  A TypeError would be raised instead of Invalid.  Seehttps://github.com/Pylons/colander/issues/111.1.0a4 (2013-05-21)Loosen Email validator regex (permit apostrophes, bang, etc in localpart).Allow for timezone info objects to be pickled and unpickled “more correctly”
(Use ‘__getinitargs__’ to provide unpickling-only defaults).  Seehttps://github.com/Pylons/colander/pull/108.1.0a3 (2013-05-16)FeaturesSupport spec-mandated truncations of ISO-8601 timezones.Support spec-mandated truncations of ISO-8601 datetimes.Allow specifying custom representations of values for boolean fields.Bug FixesEnsure thatcolander.iso8601.FixedOffsetinstances can be unpickled.Avoid validating strings as sequences under Py3k.Sync documentation with 0.9.9 change to useinsert_beforerather thanschema_order.  Seehttps://github.com/Pylons/colander/issues/1041.0a2 (2013-01-30)FeaturesAddcolander.ContainsOnlyandcolander.urlvalidators.Addcolander.instantiateto help define schemas containing
mappings and sequences more succinctly.1.0a1 (2013-01-10)Bug FixesWork around a regression in Python 3.3 forcolander.Decimalwhen it’s
used with aquantargument but without aroundingargument.
Seehttps://github.com/Pylons/colander/issues/66UsingSchemaNode(String,default='',..)now works properly, or at least
more intuitively.  Previously if an empty-stringdefaultwas supplied,
serialization would return a defaulted value ascolander.null.  Seehttps://github.com/Pylons/colander/pull/73.Stricter checking in colander.Mapping to prevent items which are logically
not mappings from being accepted during validation (seehttps://github.com/Pylons/colander/pull/96).FeaturesAddcolander.Settype, ported fromdeform.SetAdd Python 3.3 to tox configuration and use newer tox testing regime
(setup.py dev).Add Python 3.3 Trove classifier.Callingbindon a schema node e.g.cloned_node = somenode.bind(a=1, b=2)on a schema node now results in the cloned node having abindingsattribute of the value{'a':1,'b':2}.It is no longer necessary to pass atypargument to a SchemaNode
constructor if the node class has aschema_typecallable as a class
attribute which, when called with no arguments, returns a schema type.
This callable will be called to obtain the schema type if atypis not
supplied to the constructor.  The defaultSchemaNodeobject’sschema_typecallable raises aNotImplementedErrorwhen it is
called.SchemaNode now has araise_invalidmethod which accepts a message and
raises a colander.Invalid exception usingselfas the node and the
message as its message.It is now possible and advisable to subclassSchemaNodein order to
create a bundle of default node behavior.  The subclass can define the
following methods and attributes:preparer,validator,default,missing,name,title,description,widget, andafter_bind.For example, the older, more imperative style that looked like this still
works, of course:from colander import SchemaNode

ranged_int = colander.SchemaNode(
    validator=colander.Range(0, 10),
    default = 10,
    title='Ranged Int'
    )But you can alternately now do something like this:from colander import SchemaNode

class RangedIntSchemaNode(SchemaNode):
    validator = colander.Range(0, 10)
    default = 10
    title = 'Ranged Int'

ranged_int = RangedInt()Values that are expected to be callables can now alternately be methods of
the schemanode subclass instead of plain attributes:from colander import SchemaNode

class RangedIntSchemaNode(SchemaNode):
    default = 10
    title = 'Ranged Int'

    def validator(self, node, cstruct):
       if not 0 < cstruct < 10:
           raise colander.Invalid(node, 'Must be between 0 and 10')

ranged_int = RangedInt()Note that when implementing a method value such asvalidatorthat
expects to receive anodeargument,nodemust be provided in the
call signature, even thoughnodewill almost always be the same asself.  This is because Colander simply treats the method as another
kind of callable, be it a method, or a function, or an instance that has a__call__method.  It doesn’t care that it happens to be a method ofself, and it needs to support callables that are not methods, so it
sendsnodein regardless.You can’t currently usemethoddefinitions ascolander.deferredcallables.  For example this willnotwork:from colander import SchemaNode

class RangedIntSchemaNode(SchemaNode):
    default = 10
    title = 'Ranged Int'

    @colander.deferred
    def validator(self, node, kw):
       request = kw['request']
       def avalidator(node, cstruct):
           if not 0 < cstruct < 10:
               if request.user != 'admin':
                   raise colander.Invalid(node, 'Must be between 0 and 10')
       return avalidator

ranged_int = RangedInt()
bound_ranged_int = ranged_int.bind(request=request)This will result in:TypeError: avalidator() takes exactly 3 arguments (2 given)However, if you treat the thing being decorated as a function instead of a
method (remove theselfargument from the argument list), it will
indeed work):from colander import SchemaNode

class RangedIntSchemaNode(SchemaNode):
    default = 10
    title = 'Ranged Int'

    @colander.deferred
    def validator(node, kw):
       request = kw['request']
       def avalidator(node, cstruct):
           if not 0 < cstruct < 10:
               if request.user != 'admin':
                   raise colander.Invalid(node, 'Must be between 0 and 10')
       return avalidator

ranged_int = RangedInt()
bound_ranged_int = ranged_int.bind(request=request)In previous releases of Colander, the only way to defer the computation of
values was via thecolander.deferreddecorator.  In this release,
however, you can instead use thebindingsattribute ofselfto
obtain access to the bind parameters within values that are plain old
methods:from colander import SchemaNode

class RangedIntSchemaNode(SchemaNode):
    default = 10
    title = 'Ranged Int'

    def validator(self, node, cstruct):
       request = self.bindings['request']
       if not 0 < cstruct < 10:
           if request.user != 'admin':
               raise colander.Invalid(node, 'Must be between 0 and 10')

ranged_int = RangedInt()
bound_range_int = ranged_int.bind(request=request)If the things you’re trying to defer aren’t callables likevalidator,
but they’re instead just plain attributes likemissingordefault,
instead of using acolander.deferred, you can useafter_bindto set
attributes of the schemanode that rely on binding variables:from colander import SchemaNode

class UserIdSchemaNode(SchemaNode):
    title = 'User Id'

    def after_bind(self, node, kw):
        self.default = kw['request'].user.idYou can override the default values of a schemanode subclass in its
constructor:from colander import SchemaNode

class RangedIntSchemaNode(SchemaNode):
    default = 10
    title = 'Ranged Int'
    validator = colander.Range(0, 10)

ranged_int = RangedInt(validator=colander.Range(0, 20))In the above example, the validation will be done on 0-20, not 0-10.If a schema node name conflicts with a schema value attribute name on the
same class, you can work around it by giving the schema node a bogus name
in the class definition but providing a correctnameargument to the
schema node constructor:from colander import SchemaNode, Schema

class SomeSchema(Schema):
    title = 'Some Schema'
    thisnamewillbeignored = colander.SchemaNode(
                                        colander.String(),
                                        name='title'
                                        )Note that such a workaround is only required if the conflicting names are
attached to theexact sameclass definition.  Colander scrapes off schema
node definitions at each class’ construction time, so it’s not an issue for
inherited values.  For example:from colander import SchemaNode, Schema

class SomeSchema(Schema):
    title = colander.SchemaNode(colander.String())

class AnotherSchema(SomeSchema):
    title = 'Some Schema'

schema = AnotherSchema()In the above example, even though thetitle = 'Some Schema'appears to
override the superclass’titleSchemaNode, atitleSchemaNode will
indeed be present in the child list of theschemainstance
(schema['title']will return thetitleSchemaNode) and the schema’stitleattribute will beSome Schema(schema.titlewill returnSome Schema).Normal inheritance rules apply to class attributes and methods defined in
a schemanode subclass.  If your schemanode subclass inherits from another
schemanode class, your schemanode subclass’ methods and class attributes
will override the superclass’ methods and class attributes.Ordering of child schema nodes when inheritance is used works like this:
the “deepest” SchemaNode class in the MRO of the inheritance chain is
consulted first for nodes, then the next deepest, then the next, and so on.
So the deepest class’ nodes come first in the relative ordering of schema
nodes, then the next deepest, and so on.  For example:class One(colander.Schema):
    a = colander.SchemaNode(
        colander.String(),
        id='a1',
        )
    b = colander.SchemaNode(
        colander.String(),
        id='b1',
        )
    d = colander.SchemaNode(
        colander.String(),
        id='d1',
        )

class Two(One):
    a = colander.SchemaNode(
        colander.String(),
        id='a2',
        )
    c = colander.SchemaNode(
        colander.String(),
        id='c2',
        )
    e = colander.SchemaNode(
        colander.String(),
        id='e2',
        )

class Three(Two):
    b = colander.SchemaNode(
        colander.String(),
        id='b3',
        )
    d = colander.SchemaNode(
        colander.String(),
        id='d3',
        )
    f = colander.SchemaNode(
        colander.String(),
        id='f3',
        )

three = Three()The ordering of child nodes computed in the schema nodethreewill be['a2', 'b3', 'd3', 'c2', 'e2', 'f3'].  The ordering startsa1,b1,d1because that’s the ordering of nodes inOne, andOneis the deepest SchemaNode in the inheritance hierarchy.  Then it
processes the nodes attached toTwo, the next deepest, which causesa1to be replaced bya2, andc2ande2to be appended to
the node list.  Then finally it processes the nodes attached toThree,
which causesb1to be replaced byb3, andd1to be replaced byd3, then finallyfis appended.Multiple inheritance works the same way:class One(colander.Schema):
    a = colander.SchemaNode(
        colander.String(),
        id='a1',
        )
    b = colander.SchemaNode(
        colander.String(),
        id='b1',
        )
    d = colander.SchemaNode(
        colander.String(),
        id='d1',
        )

class Two(colander.Schema):
    a = colander.SchemaNode(
        colander.String(),
        id='a2',
        )
    c = colander.SchemaNode(
        colander.String(),
        id='c2',
        )
    e = colander.SchemaNode(
        colander.String(),
        id='e2',
        )

class Three(Two, One):
    b = colander.SchemaNode(
        colander.String(),
        id='b3',
        )
    d = colander.SchemaNode(
        colander.String(),
        id='d3',
        )
    f = colander.SchemaNode(
        colander.String(),
        id='f3',
        )

three = Three()The resulting node ordering ofthreeis the same as the single
inheritance example:['a2', 'b3', 'd3', 'c2', 'e2', 'f3']due to the
MRO deepest-first ordering (One, thenTwo, thenThree).Backwards IncompatibilitiesPassing non-SchemaNode derivative instances as*childreninto a
SchemaNode constructor is no longer supported.  Symptom:AttributeError: namewhen constructing a SchemaNode.0.9.9 (2012-09-24)FeaturesAllow the use ofmissing=Nonefor Number.  Seehttps://github.com/Pylons/colander/pull/59.Create acolander.Moneytype that is a Decimal type with
two-decimal-point precision rounded-up.Allowquantandroundingargs tocolander.Decimalconstructor.luhnokvalidator added (credit card luhn mod10 validator).Add aninsertmethod to SchemaNode objects.Add aninsert_beforemethod to SchemaNode objects.Better class-based mapping schema inheritance model.A node declared in a subclass of a mapping schema superclass now
overrides any node with the same name inherited from any superclass.
Previously, it just repeated and didn’t override.Aninsert_beforekeyword argument may be passed to a SchemaNode
constructor.  This is a string naming a node in a superclass.  A node
with aninsert_beforewill be placed before the named node in a
parent mapping schema.Thepreparer=argument to SchemaNodes may now be a sequence of
preparers.Added acstruct_childrenmethod to SchemaNode.A newcstruct_childrenAPI should exist on schema types.  IfSchemaNode.cstruct_childrenis called on a node with a type that does
not have acstruct_childrenmethod, a deprecation warning is emitted
and[]is returned (this may or may not be the correct value for your
custom type).Backwards IncompatibilitiesThe inheritance changes required a minor backwards incompatibility: calling__setitem__on a SchemaNode will no longer raiseKeyErrorwhen
attempting to set a subnode into a node that doesn’t already have an
existing subnode by that name.  Instead, the subnode will be appended to
the child list.DocumentationA “Schema Inheritance” section was added to the Basics chapter
documentation.0.9.8 (2012-04-27)False evaluating values are now serialized to colander.null for
String, Date, and Time.  This resolves the issue where a None value
would be rendered as ‘None’ for String, and missing=’None’ was not
possible for Date, Datetime, and Time.
Seehttps://github.com/Pylons/colander/pull/1.Updated Brazilian Portugese translations.Updated Japanese translations.Updated Russian translations.Fix documentation: 0.9.3 allowed explicitly passing None to DateTime
to have no default timezone applied.Adddevanddocssetup.py aliases (e.g.python setup.py dev).0.9.7 (2012-03-20)Usingschema.flatten(...)against a mapping schema node without a name
produced incorrectly dot-prefixed keys.  Seehttps://github.com/Pylons/colander/issues/37Fix invalid.asdict for multiple error messages.  Seehttps://github.com/Pylons/colander/pull/22,https://github.com/Pylons/colander/pull/27,https://github.com/Pylons/colander/pull/12, andhttps://github.com/Pylons/colander/issues/2.Invalid.messages() now returns an empty list if there are no messages.
Seehttps://github.com/Pylons/colander/pull/21.namepassed to a SchemaNode constructor was not respected in
declaratively constructed schemas.  Now if you passnameto the
SchemaNode constructor within the body of a schema class, it will take
precedence over the name it’s been assigned to in the schema class.
Seehttps://github.com/Pylons/colander/issues/39.Japanese translation thanks to OCHIAI, Gouji.Replaced incorrect%{err}with correct${err}in String.deserialize
error message.  Seehttps://github.com/Pylons/colander/pull/410.9.6 (2012-02-14)No longer runs on Python 2.4 or 2.5.  Python 2.6+ is now required.Python 3.2 compatibility.Removed a dependency on the iso8601 package (code from the package is now
inlined in Colander itself).Added copyright and licensing information for iso8601-derived code to
LICENSE.txt.0.9.5 (2012-01-13)Added Czech translation.Compile pt_BR translation (it was previously uncompiled).Minor docs fixes.Documentation added about flatten and unflatten.0.9.4 (2011-10-14)flattennow only includes leaf nodes in the flattened dict.flattendoes not include a path element for the name of the type node
for sequences.unflattenis implemented.Added__setitem__toSchemaNode, allowing replacement of nodes by
name.Addedget_valueandset_valuemethods toSchemawhich allow
access and mutation of appstructs using dotted name paths.Add Swedish, French, Chinese translations.0.9.3 (2011-06-23)AddTimetype.Add Dutch translation.Fix documentation: 0.9.2 requiresdeserializeof types to explicitly
deal with the potential to receivecolander.null.Usedefault_tzinfowhen deserializing naive datetimes.  Seehttps://github.com/Pylons/colander/pull/5Allowdefault_tzinfoto beNonewhen creating acolander.DateTime.  Seehttps://github.com/Pylons/colander/pull/6Add the ability to insert acolander.interfaces.Preparerbetween
deserialization and validation. See the Preparing section in the
documentation.0.9.2 (2011-03-28)Added Polish translation, thanks to Jedrzej Nowak.Moved to Pylons Project GitHub (https://github.com/Pylons/colander).Add tox.ini for testing purposes.New API:colander.required.  Used as the marker value when amissingargument is left unspecified.Bug fix: if atitleargument which is the empty string orNoneis
passed explicitly to a SchemaNode, it is no longer replaced by a title
computed from the name.Add SchemaNode.__contains__ to support “name in schema”.SchemaNode deserialization now unconditionally calls the schema type’sdeserializemethod to obtain an appstruct before attempting to
validate.  Third party schema types should now returncolander.nullif
passed acolander.nullvalue or another logically “empty” value as a
cstruct duringdeserialize.0.9.1 (2010-12-02)Whencolander.nullwas unpickled, the reference created during
unpickling wasnota reference to the singleton but rather a new instance
of thecolander._nullclass.  This was unintentional, because lots of
code checks forif x is colander.null, which will fail across pickling
and unpickling.  Now the reference created whencolander.nullis
pickled is unpickled as the singleton itself.0.9  (2010-11-28)SchemaNode constructor now accepts arbitrary keyword arguments.  It
sets any unknown values within the**kwsequence as attributes
of the node object.Added Spanish locale:  thanks to Douglas Cerna for the translations!If you use a schema with deferredvalidator,missingordefaultattributes, but you use it to perform serialization and
deserialization without calling itsbindmethod:Ifvalidatoris deferred, no validation will be performed.Ifmissingis deferred, the field will be consideredrequired.Ifdefaultis deferred, the serialization default will be
assumed to becolander.null.Undocumented internal API for all type objects:flatten.
External type objects should now inherit fromcolander.SchemaTypeto get a default implementation.0.8  (2010/09/08)Docstring fixes tocolander.SchemaNode(missingis not thenullvalue when required, it’s a special marker value).The concept of “schema binding” was added, which allows for a more
declarative-looking spelling of schemas and schema nodes which have
dependencies on values available after the schema has already been
fully constructed.  See the new narrative chapter in the
documentation entitled “Schema Binding”.The interface ofcolander.SchemaNodehas grown a__delitem__method.  The__iter__, and__getitem__methods have now also
been properly documented.0.7.3 (2010/09/02)The title of a schema node now defaults to a titleization of thename.  Underscores in thenameare replaced with empty
strings and the first letter of every resulting word is capitalized.
Previously thenamewas not split on underscores, and the
entirety of thenamewas capitalized.A method of thecolander.Invalidexception namedmessageswas added.  It returns an iterable of error messages using themsgattribute of its related exception node.  If themsgattribute is iterable, it is returned.  If it is not iterable, a
single-element list containing themsgvalue is returned.0.7.2 (2010/08/30)Add ancolander.SchemaNode.__iter__method, which iterates over
the children nodes of a schema node.The constructor of acolander.SchemaNodenow accepts awidgetkeyword argument, for use by Deform (it is not used
internally).0.7.1 (2010/06/12)Make it possible to usecolander.nullas amissingargument
tocolander.SchemaNodefor roundtripping purposes.Make it possible to picklecolander.null.0.7.0A release centered around normalizing the treatment of default and
missing values.Bug FixesAllowcolander.Regexvalidator to accept a pattern object
instead of just a string.Get rid of circular reference in Invalid exceptions: Invalid
exceptions now no longer have aparentattribute.  Instead, they
have apositionalattribute, which signifies that the parent
node type of the schema node to which they relate inherits from
Positional.  This attribute isn’t an API; it’s used only internally
for reporting.Raise aTypeErrorwhen bogus keyword arguments are passed tocolander.SchemaNode.Backwards Incompatiblities / New Featuresmissingconstructor arg to SchemaNode: signifiesdeserializationdefault, disambiguated fromdefaultwhich acted
as both serialization and deserialization default previously.Changes necessitated / made possible by SchemaNodemissingaddition:Theallow_emptyargument of thecolander.Stringtype was
removed (usemissing=''as a wrapper SchemaNode argument
instead).New concept:colander.nullinput to serialization and
deserialization.  Use ofcolander.nullnormalizes serialization
and deserialization default handling.Changes necessitated / made possible bycolander.nulladdition:partialargument and attribute of colander.MappingSchema hasbeen removed; all serializations are partial, and partial
deserializations are not necessary.colander.nullvalues are added to the cstruct for partialserializations instead of omitting missing node values from
the cstruct.colander.nullmay now be present in serialized anddeserialized data structures.sdefaultattribute of SchemaNode has been removed; we never need
to serialize a default anymore.The valuecolander.nullwill be passed asappstructto
each type’sserializemethod when a mapping appstruct doesn’t
have a corresponding key instead ofNone, as was the practice
previously.The valuecolander.nullwill be passed ascstructto
each type’sdeserializemethod when a mapping cstruct
doesn’t have a corresponding key instead ofNone, as was the
practice previously.Types now must handlecolander.nullexplicitly during
serialization.Updated and expanded documentation, particularly with respect to newcolander.nullhandling.Thevalueargument to theserializemethod of a SchemaNode
is now namedappstruct.  It is no longer a required argument; it
defaults tocolander.nullnow.Thevalueargument to thedeserializemethod of a SchemaNode
is now namedcstruct.  It is no longer a required argument; it
defaults tocolander.nullnow.Thevalueargument to theserializemethod of each built-in
type is now namedappstruct, and is now required: it is no
longer a keyword argument that has a default.Thevalueargument to thedeserializemethod of each
built-in type is now namedcstruct, and is now required: it is
no longer a keyword argument that has a default.0.6.2 (2010-05-08)The defaultencodingparameter value to thecolander.Stringtype is stillNone, however its meaning has changed.  An
encoding ofNonenow means that no special encoding and decoding
of Unicode values is done by the String type.  This differs from the
previous behavior, whereNoneimplied that the encoding wasutf-8.  Pass the encoding asutf-8specifically to get the
older behavior back.  This is in support of Deform.The defaulterr_templatevalue attached to thecolander.Dateandcolander.Datetimetypes was changed.  It is now simplyInvalid dateinstead of_('${val}cannot be parsed as an iso8601 date:${err}').  This is in support of Deform.Fix bug incolander.Booleanthat attempted to call.loweron
a bool value when a default value was found for the schema node.0.6.1 (2010-05-04)Add a Decimal type (number type which usesdecimal.Decimalas a
deserialization target).0.6.0 (2010-05-02)(Hopefully) fix intermittent datetime-granularity-related test
failures.Internationalized error messages.  This required some changes to
error message formatting, which may impact you if you were feeding
colander an error message template.New project dependency:translationstringpackage for
internationalization.New argument tocolander.Stringconstructor:allow_empty.
This is a boolean representing whether an empty string is a valid
value during deserialization, defaulting toFalse.Add minimal documentation about the composition of a
colander.Invalid exception to the narrative docs.Add (existing, but previously non-API) colander.Invalid attributes
to its interface within the API documentation.0.5.2 (2010-04-09)Add Email and Regex validators (courtesy Steve Howe).Raise acolander.Invaliderror if acolander.SequenceSchemais created with more than one member.AddFunctionvalidator.Fix bug in serialization of non-Unicode values in theStringclass.Get rid ofpserializein favor of makingserializealways
partially serialize.Get rid ofpdeserialize: it existed only for symmetry.  We’ll
add something like it back later if we need it.0.5.1 (2010-04-02)The constructor arguments to a thecolander.Schemaclass are now
sent to the constructed SchemaNode rather than to the type it represents.Allowcolander.Dateandcolander.DateTimeinvalid error
messages to be customized.Add aposargument to thecolander.Invalid.addmethod.Add a__setitem__method to thecolander.Invalidclass.Thecolander.Mappingconstructor keyword argumentunknown_keyshas been renamed tounknown.Allowcolander.Mappingtype to accept a new constructor
argument:partial.New interface methods required by types and schema nodes:pserializeandpdeserialize.  These partially serialize or
partially deserialize a value (the definition of “partial” is up to
the type).0.5 (2010-03-31)0.4 was mispackaged (CHANGES.txt missing); no code changes from 0.4
however.0.4 (2010-03-30)Addcolander.DateTimeandcolander.Datedata types.Depend on theiso8601package for date support.0.3 (2010-03-29)Subnodes of a schema node are now kept in thechildrenattribute
rather than thenodesattribute.Add ansdefaultproperty tocolander.SchemaNodeobjects.Add aclonemethod tocolander.SchemaNodeobjects.Add a__str__method to thecolander.Invalidexception that
prints an error summary.Various error message improvements.Addcolander.Lengthvalidator class.0.2 (2010-03-23)Make nodetype overrideable.Add __getitem__ to SchemaNode.Fix OneOf message.Capitalize node titles.Deal with empty strings in String, Boolean, and Float types.Introduce description; make title the same as name.Remove copy method from schemanode.Allow schema nodes to have titles.The term “structure” is too overloaded to use for schema purposes:
structure -> schema node.Make Sequence more like Tuple and Mapping (it uses a substructure
rather than a structure parameter to denote its type).Add __repr__ and copy methods to structure.Add accept_scalar flag to Sequence.0.1 (2010-03-14)Initial release.