@@ -4,6 +4,9 @@ unreleased
|
||||
- Allow deferred schema nodes.
|
||||
See https://github.com/Pylons/colander/pull/280
|
||||
|
||||
- Fix an issue when using a node multiple times in a schema by cloning it.
|
||||
See https://github.com/Pylons/colander/issues/279
|
||||
|
||||
1.3.1 (2016-05-23)
|
||||
==================
|
||||
|
||||
|
@@ -2242,7 +2242,7 @@ class _SchemaMeta(type):
|
||||
value.title = name.replace('_', ' ').title()
|
||||
nodes.append((value._order, value))
|
||||
|
||||
nodes.sort()
|
||||
nodes.sort(key=lambda n: n[0])
|
||||
cls.__class_schema_nodes__ = [ n[1] for n in nodes ]
|
||||
|
||||
# Combine all attrs from this class and its _SchemaNode superclasses.
|
||||
|
@@ -3403,6 +3403,17 @@ class TestSchema(unittest.TestCase):
|
||||
self.assertEqual(schema.schema_type, colander.Mapping)
|
||||
self.assertEqual(schema.children[0], node)
|
||||
|
||||
def test_schema_with_cloned_nodes(self):
|
||||
import colander
|
||||
test_node = colander.SchemaNode(colander.String())
|
||||
class TestSchema(colander.Schema):
|
||||
a = test_node.clone()
|
||||
b = test_node.clone()
|
||||
node = TestSchema()
|
||||
expected = {'a': 'foo', 'b': 'bar'}
|
||||
result = node.serialize(expected)
|
||||
self.assertEqual(result, expected)
|
||||
|
||||
class TestSequenceSchema(unittest.TestCase):
|
||||
def test_succeed(self):
|
||||
import colander
|
||||
|
Reference in New Issue
Block a user