Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

default empty values don't work in serialize() #180

Open
imbaczek opened this issue Jul 29, 2014 · 1 comment
Open

default empty values don't work in serialize() #180

imbaczek opened this issue Jul 29, 2014 · 1 comment

Comments

@imbaczek
Copy link

e.g.

class Data(colander.MappingSchema):
    name = colander.SchemaNode(colander.Str(), missing='', default='')

works as expected on deserialization, but not on serialization, where the node becomes null instead of ''.

@imbaczek imbaczek changed the title "if not appstruct: return null" in serialize() methods break empty values default empty values don't work in serialize() Jul 29, 2014
@imbaczek
Copy link
Author

possible fix

        cstruct = self.typ.serialize(self, appstruct)
        if cstruct is null:
            cstruct = self.default
        return cstruct

in SchemaNode.serialize

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant