move _polymorphic_iterator to PolymorphicModelIterable as there is no second compatibility code path anymore
parent
fa3b874a54
commit
f7c9df935f
|
|
@ -20,7 +20,21 @@ from .query_translate import translate_polymorphic_field_path, translate_polymor
|
||||||
Polymorphic_QuerySet_objects_per_request = 100
|
Polymorphic_QuerySet_objects_per_request = 100
|
||||||
|
|
||||||
|
|
||||||
def _polymorphic_iterator(queryset, base_iter):
|
class PolymorphicModelIterable(ModelIterable):
|
||||||
|
"""
|
||||||
|
ModelIterable for PolymorphicModel
|
||||||
|
|
||||||
|
Yields real instances if qs.polymorphic_disabled is False,
|
||||||
|
otherwise acts like a regular ModelIterable.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __iter__(self):
|
||||||
|
base_iter = super(PolymorphicModelIterable, self).__iter__()
|
||||||
|
if self.queryset.polymorphic_disabled:
|
||||||
|
return base_iter
|
||||||
|
return self._polymorphic_iterator(base_iter)
|
||||||
|
|
||||||
|
def _polymorphic_iterator(self, base_iter):
|
||||||
"""
|
"""
|
||||||
Here we do the same as::
|
Here we do the same as::
|
||||||
|
|
||||||
|
|
@ -45,7 +59,7 @@ def _polymorphic_iterator(queryset, base_iter):
|
||||||
reached_end = True
|
reached_end = True
|
||||||
break
|
break
|
||||||
|
|
||||||
real_results = queryset._get_real_instances(base_result_objects)
|
real_results = self.queryset._get_real_instances(base_result_objects)
|
||||||
|
|
||||||
for o in real_results:
|
for o in real_results:
|
||||||
yield o
|
yield o
|
||||||
|
|
@ -54,21 +68,6 @@ def _polymorphic_iterator(queryset, base_iter):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
class PolymorphicModelIterable(ModelIterable):
|
|
||||||
"""
|
|
||||||
ModelIterable for PolymorphicModel
|
|
||||||
|
|
||||||
Yields real instances if qs.polymorphic_disabled is False,
|
|
||||||
otherwise acts like a regular ModelIterable.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __iter__(self):
|
|
||||||
base_iter = super(PolymorphicModelIterable, self).__iter__()
|
|
||||||
if self.queryset.polymorphic_disabled:
|
|
||||||
return base_iter
|
|
||||||
return _polymorphic_iterator(self.queryset, base_iter)
|
|
||||||
|
|
||||||
|
|
||||||
def transmogrify(cls, obj):
|
def transmogrify(cls, obj):
|
||||||
"""
|
"""
|
||||||
Upcast a class to a different type without asking questions.
|
Upcast a class to a different type without asking questions.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue