Copy all the relevant properties of this queryset to a new queryset (which has to be an instance of :class:`~mongoengine.queryset.base.BaseQuerySet`).
(self, new_qs)
| 823 | return self._clone_into(self.__class__(self._document, self._collection_obj)) |
| 824 | |
| 825 | def _clone_into(self, new_qs): |
| 826 | """Copy all the relevant properties of this queryset to |
| 827 | a new queryset (which has to be an instance of |
| 828 | :class:`~mongoengine.queryset.base.BaseQuerySet`). |
| 829 | """ |
| 830 | if not isinstance(new_qs, BaseQuerySet): |
| 831 | raise OperationError( |
| 832 | "%s is not a subclass of BaseQuerySet" % new_qs.__name__ |
| 833 | ) |
| 834 | |
| 835 | copy_props = ( |
| 836 | "_mongo_query", |
| 837 | "_cls_query", |
| 838 | "_none", |
| 839 | "_query_obj", |
| 840 | "_where_clause", |
| 841 | "_loaded_fields", |
| 842 | "_ordering", |
| 843 | "_snapshot", |
| 844 | "_timeout", |
| 845 | "_allow_disk_use", |
| 846 | "_read_preference", |
| 847 | "_read_concern", |
| 848 | "_iter", |
| 849 | "_scalar", |
| 850 | "_as_pymongo", |
| 851 | "_limit", |
| 852 | "_skip", |
| 853 | "_empty", |
| 854 | "_hint", |
| 855 | "_collation", |
| 856 | "_search_text", |
| 857 | "_search_text_score", |
| 858 | "_max_time_ms", |
| 859 | "_comment", |
| 860 | "_batch_size", |
| 861 | ) |
| 862 | |
| 863 | for prop in copy_props: |
| 864 | val = getattr(self, prop) |
| 865 | setattr(new_qs, prop, copy.copy(val)) |
| 866 | |
| 867 | new_qs.__auto_dereference = self._BaseQuerySet__auto_dereference |
| 868 | |
| 869 | if self._cursor_obj: |
| 870 | new_qs._cursor_obj = self._cursor_obj.clone() |
| 871 | |
| 872 | return new_qs |
| 873 | |
| 874 | def select_related(self, max_depth=1): |
| 875 | """Handles dereferencing of :class:`~bson.dbref.DBRef` objects or |