Skip to main content

A simple schema-based serialization and deserialization library

Project description

Colander

An 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.

Please see http://docs.repoze.org/colander for further documentation.

Changes

0.7.0

A release centered around normalizing the treatment of default and missing values.

Bug Fixes

  • Allow colander.Regex validator to accept a pattern object instead of just a string.

  • Get rid of circular reference in Invalid exceptions: Invalid exceptions now no longer have a parent attribute. Instead, they have a positional attribute, 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 a TypeError when bogus keyword arguments are passed to colander.SchemaNode.

Backwards Incompatiblities / New Features

  • missing constructor arg to SchemaNode: signifies deserialization default, disambiguated from default which acted as both serialization and deserialization default previously.

    Changes necessitated / made possible by SchemaNode missing addition:

    • The allow_empty argument of the colander.String type was removed (use missing='' as a wrapper SchemaNode argument instead).

  • New concept: colander.null input to serialization and deserialization. Use of colander.null normalizes serialization and deserialization default handling.

    Changes necessitated / made possible by colander.null addition:

    • partial argument and attribute of colander.MappingSchema has

      been removed; all serializations are partial, and partial deserializations are not necessary.

    • colander.null values are added to the cstruct for partial

      serializations instead of omitting missing node values from the cstruct.

    • colander.null may now be present in serialized and

      deserialized data structures.

    • sdefault attribute of SchemaNode has been removed; we never need to serialize a default anymore.

    • The value colander.null will be passed as appstruct to each type’s serialize method when a mapping appstruct doesn’t have a corresponding key instead of None, as was the practice previously.

    • The value colander.null will be passed as cstruct to each type’s deserialize method when a mapping cstruct doesn’t have a corresponding key instead of None, as was the practice previously.

    • Types now must handle colander.null explicitly during serialization.

  • Updated and expanded documentation, particularly with respect to new colander.null handling.

  • The value argument`` to the serialize method of a SchemaNode is now named appstruct. It is no longer a required argument; it defaults to colander.null now.

    The value argument to the deserialize method of a SchemaNode is now named cstruct. It is no longer a required argument; it defaults to colander.null now.

  • The value argument to the serialize method of each built-in type is now named appstruct, and is now required: it is no longer a keyword argument that has a default.

    The value argument to the deserialize method of each built-in type is now named cstruct, and is now required: it is no longer a keyword argument that has a default.

0.6.2 (2010-05-08)

  • The default encoding parameter value to the colander.String type is still None, however its meaning has changed. An encoding of None now means that no special encoding and decoding of Unicode values is done by the String type. This differs from the previous behavior, where None implied that the encoding was utf-8. Pass the encoding as utf-8 specifically to get the older behavior back. This is in support of Deform.

  • The default err_template value attached to the colander.Date and colander.Datetime types was changed. It is now simply Invalid date instead of _('${val} cannot be parsed as an iso8601 date: ${err}'). This is in support of Deform.

  • Fix bug in colander.Boolean that attempted to call .lower on 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 uses decimal.Decimal as 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: translationstring package for internationalization.

  • New argument to colander.String constructor: allow_empty. This is a boolean representing whether an empty string is a valid value during deserialization, defaulting to False.

  • 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 a colander.Invalid error if a colander.SequenceSchema is created with more than one member.

  • Add Function validator.

  • Fix bug in serialization of non-Unicode values in the String class.

  • Get rid of pserialize in favor of making serialize always partially serialize.

  • Get rid of pdeserialize: 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 the colander.Schema class are now sent to the constructed SchemaNode rather than to the type it represents.

  • Allow colander.Date and colander.DateTime invalid error messages to be customized.

  • Add a pos argument to the colander.Invalid.add method.

  • Add a __setitem__ method to the colander.Invalid class.

  • The colander.Mapping constructor keyword argument unknown_keys has been renamed to unknown.

  • Allow colander.Mapping type to accept a new constructor argument: partial.

  • New interface methods required by types and schema nodes: pserialize and pdeserialize. 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)

  • Add colander.DateTime and colander.Date data types.

  • Depend on the iso8601 package for date support.

0.3 (2010-03-29)

  • Subnodes of a schema node are now kept in the children attribute rather than the nodes attribute.

  • Add an sdefault property to colander.SchemaNode objects.

  • Add a clone method to colander.SchemaNode objects.

  • Add a __str__ method to the colander.Invalid exception that prints an error summary.

  • Various error message improvements.

  • Add colander.Length validator 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

colander-0.7.0.tar.gz (48.2 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page