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

Allow providing get_schema_kwargs as a function #179

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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