- `name` passed to a SchemaNode constructor was not respected in
				
					
				
			declaratively constructed schemas. Now if you pass ``name`` to the SchemaNode constructor within the body of a schema class, it will take precedence over the name it's been assigned to in the schema class. See https://github.com/Pylons/colander/issues/39 . Fixes #39.
This commit is contained in:
		| @@ -17,6 +17,12 @@ Next release | ||||
| - Invalid.messages() now returns an empty list if there are no messages. | ||||
|   See https://github.com/Pylons/colander/pull/21 . | ||||
|  | ||||
| - ``name`` passed to a SchemaNode constructor was not respected in | ||||
|   declaratively constructed schemas.  Now if you pass ``name`` to the | ||||
|   SchemaNode constructor within the body of a schema class, it will take | ||||
|   precedence over the name it's been assigned to in the schema class. | ||||
|   See https://github.com/Pylons/colander/issues/39 . | ||||
|  | ||||
| 0.9.6 (2012-02-14) | ||||
| ------------------ | ||||
|  | ||||
|   | ||||
| @@ -1694,7 +1694,8 @@ class _SchemaMeta(type): | ||||
|         nodes = [] | ||||
|         for name, value in clsattrs.items(): | ||||
|             if isinstance(value, SchemaNode): | ||||
|                 value.name = name | ||||
|                 if not value.name: | ||||
|                     value.name = name | ||||
|                 if value.raw_title is _marker: | ||||
|                     value.title = name.replace('_', ' ').title() | ||||
|                 nodes.append((value._order, value)) | ||||
|   | ||||
| @@ -2102,6 +2102,18 @@ class TestSchemaNode(unittest.TestCase): | ||||
|         self.assertEqual(len(outer_clone.children), 0) | ||||
|         self.assertEqual(len(outer_node.children), 1) | ||||
|  | ||||
|     def test_declarative_name_reassignment(self): | ||||
|         # see https://github.com/Pylons/colander/issues/39 | ||||
|         import colander | ||||
|         class FnordSchema(colander.Schema): | ||||
|             fnord = colander.SchemaNode( | ||||
|                 colander.Sequence(),  | ||||
|                 colander.SchemaNode(colander.Integer(), name=''),  | ||||
|                 name="fnord[]" | ||||
|                 ) | ||||
|         schema = FnordSchema() | ||||
|         self.assertEqual(schema['fnord[]'].name, 'fnord[]') | ||||
|          | ||||
| class TestDeferred(unittest.TestCase): | ||||
|     def _makeOne(self, wrapped): | ||||
|         from colander import deferred | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Chris McDonough
					Chris McDonough