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
Make it easy to parse a Pagination object to dict #482
Comments
Hello, i want to contribute but i didn't understand what you need. You want to realize additional method at Pagination class something like this:
? |
Not |
We can do it like this, add two methods to class class Pagination:
...
def __getitem__(self, key):
return getattr(self, key)
def keys(self):
return ('page', 'pages', 'total', 'has_prev', 'next_num', 'has_next', 'items') Now, data = dict(pagination)
data['items'] = some_handle_for(data['items']) Since items may be not JSON serializable, so it should be handle separately. |
Wouldn't it be most appropriate to implement a |
The problem with an The direct way for a dev to handle this, although not the most powerful, is to implement their own We do not want to take on maintaining a serialization library for result rows or SQLAlchemy models. This is better handled by a serialization library such as Marshmallow, Marshmallow-SQLAlchemy, and Marshmallow-Flask, or another API extension. At which point, that can also handle serializing a |
Closing based on above comment and discussion in #748. |
Being able to easely parse a Pagination object to dict would make it much more "ajax" friendly.
The text was updated successfully, but these errors were encountered: