Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Missing drop #98

merged 2 commits into from

3 participants


I basically just added some docs to issue #84. Seems ready to go to me.

@mcdonc mcdonc merged commit a564f43 into Pylons:master

Thanks for adding docs, Joe.

I always appreciate having a "How to submit patches" checklist in the library docs, to help make sure I touch all the bases when submitting. Does Colander have one of those?

Something like:

  • Clone the repo
  • Create a branch for your patch
  • Write code
  • Add tests
  • Add docs if the patch introduces a new feature
  • Submit pull request

I know that workflow is pretty much standard, but it's always nice to be explicit about it anyway. I'd be happy to add docs for this if it doesn't already exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 20, 2013
  1. @abrookins
Commits on Mar 19, 2013
  1. @jayd3e
This page is out of date. Refresh to see the latest.
18 colander/
@@ -40,6 +40,15 @@ def __reduce__(self):
null = _null()
+class _drop(object):
+ """
+ Represents a value that should be dropped if it is missing during
+ deserialization.
+ """
+ pass
+drop = _drop()
def interpolate(msgs):
for s in msgs:
if hasattr(s, 'interpolate'):
@@ -531,11 +540,14 @@ def _impl(self, node, value, callback):
name =
subval = value.pop(name, null)
- result[name] = callback(subnode, subval)
+ sub_result = callback(subnode, subval)
except Invalid as e:
if error is None:
error = Invalid(node)
error.add(e, num)
+ else:
+ if sub_result is not drop:
+ result[name] = sub_result
if self.unknown == 'raise':
if value:
@@ -1640,7 +1652,9 @@ class _SchemaNode(object):
not provided, the missing value of this node will be the special marker
value :attr:`colander.required`, indicating that it is considered
'required'. When ``missing`` is :attr:`colander.required`, the
- ``required`` computed attribute will be ``True``.
+ ``required`` computed attribute will be ``True``. When ``missing`` is
+ :attr:`colander.drop`, the node is dropped from the schema if it isn't
+ set during serialization/deserialization.
- ``preparer``: Optional preparer for this node. It should be
an object that implements the
10 colander/tests/
@@ -2895,6 +2895,16 @@ class MySchema(colander.Schema):
self.assertEqual(node.children[2].title, '')
self.assertEqual(node.children[3].title, 'thing2')
+ def test_deserialize_drop(self):
+ import colander
+ class MySchema(colander.Schema):
+ a = colander.SchemaNode(colander.String())
+ b = colander.SchemaNode(colander.String(), missing=colander.drop)
+ node = MySchema()
+ expected = {'a': 'test'}
+ result = node.deserialize(expected)
+ self.assertEqual(result, expected)
class TestSequenceSchema(unittest.TestCase):
def test_succeed(self):
import colander
4 docs/api.rst
@@ -139,3 +139,7 @@ Schema-Related
.. attribute:: required
Represents a required value in colander-related operations.
+ .. attribute:: drop
+ Represents a value that will be dropped from the schema if it is missing. Passed
+ ass a value to the `missing` keyword argument.
Something went wrong with that request. Please try again.