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

Add load_only and dump_only options #131

Merged
merged 5 commits into from
Jan 25, 2015
Merged

Add load_only and dump_only options #131

merged 5 commits into from
Jan 25, 2015

Conversation

philtay
Copy link
Contributor

@philtay philtay commented Jan 21, 2015

Docstrings and unit tests are still missing. Let me know if these changes are ok and I'll add them.

@@ -290,6 +294,8 @@ def deserialize(self, data, fields_dict, many=False, validators=None,
exception_class=UnmarshallingError,
strict=strict
)
if field_obj.dump_only:
Copy link
Member

Choose a reason for hiding this comment

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

This should go before the call to _call_and_store. If the field dump-only, no need to do the work of deserializing the value and validating it.

@sloria
Copy link
Member

sloria commented Jan 22, 2015

Thanks! Just a minor change to make. Once the tests and docs are added, this is good to merge.

@philtay
Copy link
Contributor Author

philtay commented Jan 22, 2015

Done.

if (value is missing) or (skip_missing and
value in field_obj.SKIPPABLE_VALUES):
skip_conds = (
field_obj.load_only,
Copy link
Member

Choose a reason for hiding this comment

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

Actually, we can check field_obj.load_only before running _call_and_store as well.

@sloria
Copy link
Member

sloria commented Jan 23, 2015

Thanks for adding tests and docs. Just one last change and this is good to merge.

@philtay
Copy link
Contributor Author

philtay commented Jan 23, 2015

Uhm, no, we can't. This test is going to fail:

https://github.com/marshmallow-code/marshmallow/blob/dev/tests/test_schema.py#L362

This is the reason why I initially put them both after _call_and_store.

@sloria sloria added this to the 2.0-a milestone Jan 24, 2015
@sloria
Copy link
Member

sloria commented Jan 25, 2015

OK. I see. Thanks

@sloria sloria merged commit 68d0c62 into marshmallow-code:dev Jan 25, 2015
This was referenced Jan 25, 2015
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.

2 participants