From b45d9be152d5ee69c0a50ce0949f7cbe928358e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Command=C3=A9?= Date: Sat, 11 Oct 2014 14:15:49 +0200 Subject: [PATCH 1/2] Fix sequences flatten method --- colander/__init__.py | 2 +- colander/tests/test_colander.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/colander/__init__.py b/colander/__init__.py index 82eb96b..30d9490 100644 --- a/colander/__init__.py +++ b/colander/__init__.py @@ -466,7 +466,7 @@ class SchemaType(object): selfname = prefix else: selfname = '%s%s' % (prefix, node.name) - result[selfname] = appstruct + result[selfname.rstrip('.')] = appstruct return result def unflatten(self, node, paths, fstruct): diff --git a/colander/tests/test_colander.py b/colander/tests/test_colander.py index 4ff4939..c922968 100644 --- a/colander/tests/test_colander.py +++ b/colander/tests/test_colander.py @@ -1309,6 +1309,16 @@ class TestSequence(unittest.TestCase): result = typ.flatten(node, [1, 2]) self.assertEqual(result, {'node.0': 1, 'node.1': 2}) + def test_flatten_with_integer(self): + from colander import Integer + node = DummySchemaNode(None, name='node') + node.children = [ + DummySchemaNode(Integer(), name='foo'), + ] + typ = self._makeOne() + result = typ.flatten(node, [1, 2]) + self.assertEqual(result, {'node.0': 1, 'node.1': 2}) + def test_flatten_listitem(self): node = DummySchemaNode(None, name='node') node.children = [ From 29c893088b743b9f5d2ebe15e1cc9e42f23d852a Mon Sep 17 00:00:00 2001 From: Romain Commande Date: Mon, 8 Dec 2014 18:16:42 +0100 Subject: [PATCH 2/2] Documented changes and added name to contributors --- CHANGES.txt | 3 +++ CONTRIBUTORS.txt | 1 + 2 files changed, 4 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index da20d24..fd37870 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -27,6 +27,9 @@ Bug Fixes See https://github.com/Pylons/colander/pull/183 and https://github.com/Pylons/colander/pull/185 +- Fix an issue where the ``flatten()'' method produces an invalid name (ex: "answer.0.") for the type "Sequence" + https://github.com/Pylons/colander/issues/179 + Features ~~~~~~~~ diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 6c6130b..bdd654f 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -119,3 +119,4 @@ Contributors - Cédric Messiant, 2014/06/27 - Gouji Ochiai, 2014/08/21 - Tim Tisdall, 2014/09/10 +- Romain Commandé, 2014/10/11