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

Replace read_only parameter with a list of HTTP methods #121

Open
dantownsend opened this issue Dec 21, 2021 · 3 comments
Open

Replace read_only parameter with a list of HTTP methods #121

dantownsend opened this issue Dec 21, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@dantownsend
Copy link
Member

dantownsend commented Dec 21, 2021

PiccoloCRUD has an option called read_only.

I think it's worth phasing this out in favour of an argument called methods.

It could be something like:

PiccoloCRUD(methods=[HTTP.get])

If read_only is provided in kwargs, then we can just map that to methods=[HTTP.get] and provide a deprecation warning.

It means you have more fine grained control over which methods to expose:

PiccoloCRUD(methods=[HTTP.get, HTTP.post])
@dantownsend dantownsend added the enhancement New feature or request label Dec 21, 2021
@sinisaos
Copy link
Member

sinisaos commented Dec 21, 2021

@dantownsend I don't think we should change this because read_only is a good, safe and simple mechanism (if we pass True to read_only only the GET method is allowed, otherwise all methods are allowed) to show or hide unsafe endpoints. The documentation around that is also good. Sorry if I miss the point.

@dantownsend
Copy link
Member Author

@sinisaos I can imagine use cases where you just want to use part of PiccoloCRUD. At the moment, there's just the option for GET, or everything.

I agree that read_only is very convenient and easy to understand, but it doesn't support the middle ground where maybe you want GET and POST, but not PATCH, PUT and DELETE.

I don't think it's high priority, but maybe let's keep it open, and see if anybody else encounters this issue, in which case we can prioritise it. Or there might even be a better solution to just exposing certain methods.

@sinisaos
Copy link
Member

@dantownsend You're right. Probably most users want to use all CRUD methods, but yes, there may be some edge cases where some users only wants certain methods. Sorry, I didn't think of this that way. Thank you for the explanation. Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants