Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

tweaks to writable nested serializers #739

Conversation

craigds
Copy link
Contributor

@craigds craigds commented Mar 18, 2013

allows required and default kwargs in field constructor for serializers.

@@ -360,7 +360,9 @@ def field_from_native(self, data, files, field_name, into):
except KeyError:
if self.required:
raise ValidationError(self.error_messages['required'])
return
if self.default is None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably mirror the WritableField style:

if self.default is not None and not self.partial:
    # Note: partial updates shouldn't set defaults
    value = copy.deepcopy(self.default)
else:
    if self.required:
        raise ValidationError(self.error_messages['required'])
        return

@maspwr
Copy link
Contributor

maspwr commented Mar 18, 2013

LGTM. I'll let @tomchristie handle merging it in if he wants.

@maspwr
Copy link
Contributor

maspwr commented Mar 18, 2013

Also, have you done much testing with this branch? I'd be interested to get some feedback on real world usage.

@craigds
Copy link
Contributor Author

craigds commented Mar 18, 2013

@maspwr We're not using the branch in production yet, just on my dev VM. It's going to be an export API for http://koordinates.com . Basically you can create a download of some spatial data by posting to the API. A typical post might look something like https://gist.github.com/craigds/15a5aeffe3e831018547

@maspwr
Copy link
Contributor

maspwr commented Mar 18, 2013

OK, cool. Looks like pretty typical usage. Let us know if you run into any issues. Thanks for the info!

tomchristie added a commit that referenced this pull request Mar 18, 2013
tweaks to writable nested serializers
@tomchristie tomchristie merged commit 75fbfb5 into encode:basic-nested-serialization Mar 18, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants