-
Notifications
You must be signed in to change notification settings - Fork 144
Open
Description
Some code chunk:
#!/usr/bin/env python
from __future__ import print_function
import copy
import pprint
from colander import MappingSchema
from colander import SchemaNode
from colander import String
from colander import drop
class StrictMappingSchema(MappingSchema):
@staticmethod
def schema_type():
return MappingSchema.schema_type(unknown='raise')
class StrictSchema(StrictMappingSchema):
foo = SchemaNode(String(), type='str', missing=drop)
bar = SchemaNode(String(), type='str')
class NestedSchema(MappingSchema):
egg = StrictSchema()
ham = StrictSchema()
data = {'egg.bar': 'GET', 'ham': {'bar': 'POST'}}
schema = NestedSchema()
print('original data:')
pprint.pprint(data)
print('\nunflattened data:')
unflattened = copy.deepcopy(data)
pprint.pprint(schema.unflatten(unflattened))It's output:
original data:
{'egg.bar': 'GET', 'ham': {'bar': 'POST'}}
unflattened data:
{'egg': {'bar': 'GET'}, 'ham': {}}
As you can see - we have lost content of original 'ham' key. Is it a bug or just .unflatten feature?
Metadata
Metadata
Assignees
Labels
No labels