A non caching QuerySet
| 157 | |
| 158 | |
| 159 | class QuerySetNoCache(BaseQuerySet): |
| 160 | """A non caching QuerySet""" |
| 161 | |
| 162 | def cache(self): |
| 163 | """Convert to a caching queryset""" |
| 164 | return self._clone_into(QuerySet(self._document, self._collection)) |
| 165 | |
| 166 | def __repr__(self): |
| 167 | """Provides the string representation of the QuerySet""" |
| 168 | if self._iter: |
| 169 | return ".. queryset mid-iteration .." |
| 170 | |
| 171 | data = [] |
| 172 | for _ in range(REPR_OUTPUT_SIZE + 1): |
| 173 | try: |
| 174 | data.append(next(self)) |
| 175 | except StopIteration: |
| 176 | break |
| 177 | |
| 178 | if len(data) > REPR_OUTPUT_SIZE: |
| 179 | data[-1] = "...(remaining elements truncated)..." |
| 180 | |
| 181 | self.rewind() |
| 182 | return repr(data) |
| 183 | |
| 184 | def __iter__(self): |
| 185 | queryset = self |
| 186 | if queryset._iter: |
| 187 | queryset = self.clone() |
| 188 | queryset.rewind() |
| 189 | return queryset |