Fixed queryset processing for real (another merge fix for pr #279)

fix_request_path_info
Diederik van der Boor 2017-04-26 16:44:54 +02:00
parent 09d785f5bb
commit 61b398115b
1 changed files with 11 additions and 9 deletions

View File

@ -35,18 +35,20 @@ def _polymorhic_iterator(queryset, base_iter):
but it requests the objects in chunks from the database, but it requests the objects in chunks from the database,
with Polymorphic_QuerySet_objects_per_request per chunk with Polymorphic_QuerySet_objects_per_request per chunk
""" """
# Make sure the base iterator is read in chunks instead of while True:
# reading it completely, in case our caller read only a few objects.
for i in range(Polymorphic_QuerySet_objects_per_request):
base_result_objects = [] base_result_objects = []
reached_end = False reached_end = False
try: # Make sure the base iterator is read in chunks instead of
o = next(base_iter) # reading it completely, in case our caller read only a few objects.
base_result_objects.append(o) for i in range(Polymorphic_QuerySet_objects_per_request):
except StopIteration:
reached_end = True try:
break o = next(base_iter)
base_result_objects.append(o)
except StopIteration:
reached_end = True
break
real_results = queryset._get_real_instances(base_result_objects) real_results = queryset._get_real_instances(base_result_objects)