Call a particular method on the PyMongo cursor call a particular chainable method with the provided value.
(self, method_name, val)
| 2017 | return code |
| 2018 | |
| 2019 | def _chainable_method(self, method_name, val): |
| 2020 | """Call a particular method on the PyMongo cursor call a particular chainable method |
| 2021 | with the provided value. |
| 2022 | """ |
| 2023 | queryset = self.clone() |
| 2024 | |
| 2025 | # Get an existing cursor object or create a new one |
| 2026 | cursor = queryset._cursor |
| 2027 | |
| 2028 | # Find the requested method on the cursor and call it with the |
| 2029 | # provided value |
| 2030 | getattr(cursor, method_name)(val) |
| 2031 | |
| 2032 | # Cache the value on the queryset._{method_name} |
| 2033 | setattr(queryset, "_" + method_name, val) |
| 2034 | |
| 2035 | return queryset |
no test coverage detected