Permalink
Commits on Jan 11, 2013
  1. specify

    mcdonc committed Jan 11, 2013
  2. prep for 1.0a1

    mcdonc committed Jan 11, 2013
Commits on Jan 10, 2013
  1. add Py33 trove classifier

    mcdonc committed Jan 10, 2013
  2. make tests pass on 3.2

    mcdonc committed Jan 10, 2013
  3. add change note

    mcdonc committed Jan 10, 2013
  4. Merge branch 'string_type_serialize_empty_string' of git://github.com…

    …/tranminhh/colander into tranminhh-string_type_serialize_empty_string
    mcdonc committed Jan 10, 2013
Commits on Dec 10, 2012
  1. Merge pull request #76 from aiurdoo/master

    Documentation fixes.
    dnouri committed Dec 10, 2012
  2. fix formatting typo in the docs

    Attila Oláh committed Dec 10, 2012
Commits on Nov 21, 2012
  1. Merge pull request #71 from Pylons/feature.Set

    Add Set schematype (backported from deform.Set)
    mcdonc committed Nov 21, 2012
Commits on Nov 16, 2012
  1. Make String serialize empty string to empty string instead of null

    This makes the following True:
    ``` String().serialize(node, u'') == u'' ```
    
    Issue #72
    tranminhh committed Nov 16, 2012
Commits on Nov 10, 2012
  1. empty set is a valid cstruct

    domenkozar committed Nov 10, 2012
  2. Add Set schematype

    domenkozar committed Nov 10, 2012
Commits on Oct 10, 2012
  1. vb

    mcdonc committed Oct 10, 2012
Commits on Oct 9, 2012
  1. update docs

    mcdonc committed Oct 9, 2012
  2. quote things

    mcdonc committed Oct 9, 2012
  3. indentation

    mcdonc committed Oct 9, 2012
  4. explain inheritance rules

    mcdonc committed Oct 9, 2012
Commits on Oct 8, 2012
  1. update

    mcdonc committed Oct 8, 2012
Commits on Oct 7, 2012
  1. Features

    ~~~~~~~~
    
    - Calling ``bind`` on a schema node e.g. ``cloned_node = somenode.bind(a=1,
      b=2)`` on a schema node now results in the cloned node having a
      ``bindings`` attribute of the value ``{'a':1, 'b':2}``.
    
    - It is no longer necessary to pass a ``typ`` argument to a SchemaNode
      constructor if the node class has a ``__schema_type__`` callable 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 a ``typ`` is not
      supplied to the constructor.  The default ``SchemaNode`` object's
      ``__schema_type__`` callable raises a ``NotImplementedError`` when it is
      called.
    
    - SchemaNode now has a ``raise_invalid`` method which accepts a message and
      raises a colander.Invalid exception using ``self`` as the node and the
      message as its message.
    
    - It is now possible and advisable to subclass ``SchemaNode`` in 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``, and
      ``after_bind``.  For example, the older, more imperative style that
      looked like this still works::
    
         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::
    
         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 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()
    
       When implementing a method value that expects ``node``, ``node`` must be
       provided in the call signature, even though ``node`` will almost always be
       the same as ``self``.  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 of ``self``, and it needs to support callables that are not
       methods, so it sends ``node`` in regardless.
    
       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.
    
       Method values that need to be deferred for binding cannot currently be
       implemented as ``colander.deferred`` callables.  For example this will
       *not* work::
    
         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)
    
       Instead of trying to defer methods via a decorator, you can instead use
       the ``bindings`` attribute of ``self`` to obtain access to the bind
       parameters within values that are methody::
    
         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)
    
       You can use ``after_bind`` to set attributes of the schemanode that rely
       on binding variables, such as ``missing`` and ``default``::
    
         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')
    
             def after_bind(self, node, kw):
                 self.request = kw['request']
                 self.default = self.request.user.id
    
       Non-method values can still be implemented as ``colander.deferred``
       however::
    
         from colander import SchemaNode
    
         def _missing(node, kw):
             request = kw['request']
             if request.user.name == 'admin':
                 return 10
              return 20
    
         class RangedIntSchemaNode(SchemaNode):
             default = 10
             title = 'Ranged Int'
             missing = colander.deferred(_missing)
    
         ranged_int = RangedInt()
    
       You 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 your schema node names conflict with schema value attribute names, you
       can work around it with the ``name`` argument to the schema node::
    
         from colander import SchemaNode, Schema
    
         class TitleNode(SchemaNode):
             validator = colander.range(0, 10)
             default = 10
    
         class SomeSchema(Schema):
             title = 'Some Schema'
             thisnamewontmatter = TitleNode(name='title')
    
    Backwards Incompatibilities
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    - Passing non-SchemaNode derivative instances as ``*children`` into a
      SchemaNode constructor is no longer supported.  Symptom: ``AttributeError:
      name`` when constructing a SchemaNode.
    mcdonc committed Oct 7, 2012
Commits on Oct 2, 2012
  1. - Work around a regression in Python 3.3 for ``colander.Decimal`` whe…

    …n it's
    
      used with a ``quant`` argument but without a ``rounding`` argument.
      See #66
    
    - Add Python 3.3 to tox configuration and use newer tox testing regime
      (setup.py dev).
    
    Closes #66
    mcdonc committed Oct 2, 2012
Commits on Sep 24, 2012
  1. prep for 0.9.9

    mcdonc committed Sep 24, 2012
  2. garden

    mcdonc committed Sep 24, 2012
  3. docs

    mcdonc committed Sep 24, 2012
  4. garden

    mcdonc committed Sep 24, 2012
  5. add tests for cstruct_children

    mcdonc committed Sep 24, 2012
  6. fix tuple cstruct_children bug

    mcdonc committed Sep 24, 2012
Commits on Sep 23, 2012
  1. add a warning

    mcdonc committed Sep 23, 2012