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

pymongo: integration of get_query into get_list method #2372

Open
MihailMiller opened this issue Jul 31, 2023 · 0 comments
Open

pymongo: integration of get_query into get_list method #2372

MihailMiller opened this issue Jul 31, 2023 · 0 comments

Comments

@MihailMiller
Copy link

MihailMiller commented Jul 31, 2023

In the current pymongo implementation of the get_list method in the ModelView class, the default query is defined as {}. There is no way to override this query without overriding get_list, which makes the code less maintainable. For example, the sqla contribution allows you to override the get_query when subclassing the ModelView.

I propose to include a get_query call in the get_list method. This change would allow developers to override only the get_query method and pre-filter the database so that only relevant results are displayed according to the specific parameters of the use case.

Proposed change:

Revise get_list in ModelView to call get_query:

def get_query():
    return {}

def get_list(self, page, sort_column, sort_desc, search, filters, execute=True, page_size=None):
    query = self.get_query()
    # continue existing logic...

I will be happy to make a pull request if you would like to integrate this into the pymongo contribution.

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

No branches or pull requests

1 participant