Skip to content

Improvement: Schema tags: added "order" option#654

Closed
vgavro wants to merge 2 commits intomarshmallow-code:devfrom
vgavro:dev
Closed

Improvement: Schema tags: added "order" option#654
vgavro wants to merge 2 commits intomarshmallow-code:devfrom
vgavro:dev

Conversation

@vgavro
Copy link
Contributor

@vgavro vgavro commented Jul 5, 2017

For now, if you're using mixins or subclassing marshmallow-sqlalchemy (which is using @post_load for model creation), tags would be invoked in alphabetically order (because they're relying on dir() accessing attribute, which is not obvious anyway, and better be documented?). I think it would be better to pass verbose "order" argument, to make more complex mixins and schema subclassing. Please consider this PR, if you think it's ok I'll add tests and changes in documentation. Thank you.
Use-cases: data changes in @post_load and @pre_load, on which other mixins or subclasses may be relying.

@vgavro
Copy link
Contributor Author

vgavro commented Jul 8, 2017

note that this PR is backward-compatible: so if you're relying on alphabetic order of method name it will remain with default sort value.

@sloria
Copy link
Member

sloria commented Jul 16, 2017

Thanks for the PR! This is very similar to #600 . I think "order" may be more intuitive than "priority". That said, I'm still not sure whether this is necessary. See the discussion on #600: most use-cases should be covered by using a single pre/post method that calls other methods in order.

@sloria
Copy link
Member

sloria commented Jul 21, 2017

Closing this for now. Further discussion of this should happen in #600

@sloria sloria closed this Jul 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants