Skip to content

Conversation

multimeric
Copy link
Contributor

Allows users to provide fields like get_schema_kwargs as functions instead of dictionaries. These functions have access to the view's args and kwargs.

For example:

    class PersonDetail(ResourceDetail):
        schema = person_schema
        data_layer = {
            'model': person_model,
            'session': session,
            'url_field': 'person_id'
        }

        def get_schema_kwargs(self, args, kwargs):
            return dict(
                exclude=['name']
            )

You can still use the simpler method of providing a dictionary, too.

I've added two tests for these two use-cases.

@multimeric multimeric changed the title Get schema kwargs Allow providing get_schema_kwargs as a function Nov 11, 2019
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.06%) to 90.709% when pulling 5388686 on TMiguelT:get_schema_kwargs into b44bc08 on miLibris:master.

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

Successfully merging this pull request may close these issues.

2 participants