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

Class-based APIs #242

Open
joelcox opened this issue Sep 16, 2013 · 2 comments
Open

Class-based APIs #242

joelcox opened this issue Sep 16, 2013 · 2 comments

Comments

@joelcox
Copy link

joelcox commented Sep 16, 2013

This is mostly syntactic sugar, but when you're adding a lot of pre-/post processors the api.create_api functions becomes really big and unwieldy. Would it be an idea to make Restless more class-oriented?

Post/pre processors would work the same way and will be executed if they are defined as methods. The only thing I'm not sure about is having multiple post/pre processors, maybe through inheritance?

class PostsResource(flask.ext.restless.Resource):

    model = models.Post
    collection_name = 'posts'
    methods = ['GET', 'POST', 'DELETE']

    ...

    def pre_post_single(self, data=None, **kwags):
        pass

api.add_resource(PostResource, '/posts')

If people are interested in this improvement I'd like to take a stab at it.

@jfinkels
Copy link
Owner

I'm not sure about this. There are other Flask extensions that allow the user to create APIs using class-based "Resources", so I'd prefer to leave that style to those other extensions (even if it is more flexible or cleaner in some ways).

@joelcox
Copy link
Author

joelcox commented Sep 23, 2013

You're right. I was drawn to Restless because of the great pre/post-processor support, but missed the class-based approach. I think I'll cook something up myself for this project :).

On Sep 23, 2013, at 6:18 AM, jfinkels [email protected] wrote:

I'm not sure about this. There are other Flask extensions that allow the user to create APIs using class-based "Resources", so I'd prefer to leave that style to those other extensions (even if it is more flexible or cleaner in some ways).


Reply to this email directly or view it on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants