Make sure that the last RSM stanza is returned from the iterator
This commit is contained in:
parent
4a4a03858e
commit
5af2f62c04
1 changed files with 4 additions and 1 deletions
|
@ -47,6 +47,7 @@ class ResultIterator():
|
||||||
self.start = start
|
self.start = start
|
||||||
self.interface = interface
|
self.interface = interface
|
||||||
self.reverse = reverse
|
self.reverse = reverse
|
||||||
|
self._stop = False
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
return self
|
return self
|
||||||
|
@ -62,6 +63,8 @@ class ResultIterator():
|
||||||
results will be the items before the current page
|
results will be the items before the current page
|
||||||
of items.
|
of items.
|
||||||
"""
|
"""
|
||||||
|
if self._stop:
|
||||||
|
raise StopIteration
|
||||||
self.query[self.interface]['rsm']['before'] = self.reverse
|
self.query[self.interface]['rsm']['before'] = self.reverse
|
||||||
self.query['id'] = self.query.stream.new_id()
|
self.query['id'] = self.query.stream.new_id()
|
||||||
self.query[self.interface]['rsm']['max'] = str(self.amount)
|
self.query[self.interface]['rsm']['max'] = str(self.amount)
|
||||||
|
@ -84,7 +87,7 @@ class ResultIterator():
|
||||||
first = int(r[self.interface]['rsm']['first_index'])
|
first = int(r[self.interface]['rsm']['first_index'])
|
||||||
num_items = len(r[self.interface]['substanzas'])
|
num_items = len(r[self.interface]['substanzas'])
|
||||||
if first + num_items == count:
|
if first + num_items == count:
|
||||||
raise StopIteration
|
self._stop = True
|
||||||
|
|
||||||
if self.reverse:
|
if self.reverse:
|
||||||
self.start = r[self.interface]['rsm']['first']
|
self.start = r[self.interface]['rsm']['first']
|
||||||
|
|
Loading…
Reference in a new issue