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

allow inherited resource class to be added #19

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

Conversation

ollofx
Copy link

@ollofx ollofx commented Jun 30, 2017

add_resource method of Api class searches for declared methods ['GET','POST'...] inside:
f = resource.dict.get(method, None)
dict only reflect the local class methods to be able to reflect base class method we can use
f = getattr(resource,method)
this will allow for instance to inherit a base class CustomerResource(Resource) which has property many=False into another class CustomersResource(CustomerResource) with many=True overloaded
then we could declare:
api.add_resource(CustomerResource, '/api/customer')
api.add_resource(CustomersResource, '/api/customers')

@dmytrokyrychuk
Copy link

Hi @ollofx, I was just passing by and noticed that you used the future package here. I think it's better to use six instead because Flask-RESTful already uses it, and anyone who uses this package is most likely using Flask-RESTful too, and therefore they will have six installed anyway. I think there is no need to install two libraries that provide similar features.

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