- The constructor of a `colander.SchemaNode` now accepts a

``widget`` keyword argument, for use by Deform (it is not used
  internally).
This commit is contained in:
Chris McDonough
2010-08-30 02:44:56 +00:00
parent 60df7fea15
commit 18c21babed
3 changed files with 13 additions and 1 deletions

View File

@@ -7,6 +7,10 @@ Next release
- Add an ``colander.SchemaNode.__iter__`` method, which iterates over
the children nodes of a schema node.
- The constructor of a ``colander.SchemaNode`` now accepts a
``widget`` keyword argument, for use by Deform (it is not used
internally).
0.7.1 (2010/06/12)
------------------

View File

@@ -1158,6 +1158,9 @@ class SchemaNode(object):
``''`` (the empty string). The description is used by
higher-level systems (not by Colander itself).
- ``widget``: The 'widget' for this node. Defaults to ``None``.
The widget attribute is not interpreted by Colander itself, it
is only meaningful to higher-level systems such as Deform.
"""
_counter = itertools.count()
@@ -1175,6 +1178,7 @@ class SchemaNode(object):
self.name = kw.pop('name', '')
self.title = kw.pop('title', self.name.capitalize())
self.description = kw.pop('description', '')
self.widget = kw.pop('widget', None)
if kw:
raise TypeError('Unknown keyword arguments: %s' % repr(kw))
self.children = list(children)

View File

@@ -1296,7 +1296,11 @@ class TestSchemaNode(unittest.TestCase):
title='title', description='desc')
self.assertEqual(node.description, 'desc')
def test_ctor_with_bad_kwarg(self):
def test_ctor_with_widget(self):
node = self._makeOne(None, 0, widget='abc')
self.assertEqual(node.widget, 'abc')
def test_ctor_with_bad_kwargs(self):
self.assertRaises(TypeError, self._makeOne, None, 0, foo=1)
def test_required_true(self):