-
Notifications
You must be signed in to change notification settings - Fork 25
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
Improve limit and offset in PiccoloCRUD #14
Comments
Hi Daniel
If we want to change |
@sinisaos I think just setting The user should never be able to override this using URL params.
It's a good point with the CSV download. We could expose the |
@dantownsend We can do this via constructor and make changes like you said, but if we set max_page_size as a class variable and set it to 1000 (like code example in above comment), we only need to make changes to |
@sinisaos I think adding it to the constructor should be OK. class PiccoloCRUD(Router):
"""
Wraps a Piccolo table with CRUD methods for use in a REST API.
"""
def __init__(
self,
table: t.Type[Table],
read_only: bool = True,
allow_bulk_delete: bool = False,
page_size: int = 15,
max_page_size: int = 1000
) -> None:
self.max_page_size = max_page_size
... If the default is set to 1000, it shouldn't effect much of the existing code. |
@dantownsend It's OK if you don't override in instance with
and we need to change more files in If |
@sinisaos Ah, I understand now! Sorry. What you're saying, is don't make the maximum configurable at all. I think that works for a first version, and as you say, it means less changes to other code. |
@dantownsend Yes exactly that :). If you want I can make PR with this code changes that you can make proper look at this. |
@sinisaos That would be great - thanks! |
@dantownsend Done. Cheers. |
Currently, the
__page
and__page_size
query params aren't documented.Also,
PiccoloCRUD
should have amax_page_size
argument, to limit abuse of an endpoint.If the
max_page_size
is exceeded, an error should be returned. A 403 feels most appropriate, with a body such asThe page size limit has been exceeded
.The text was updated successfully, but these errors were encountered: