Skip to content

Commit

Permalink
The next_page() method on index pages now returns None if there is no…
Browse files Browse the repository at this point in the history
… next page.
  • Loading branch information
jerith committed Jan 30, 2015
1 parent be00af4 commit 86dd92c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions vumi/persist/riak_manager.py
Expand Up @@ -62,6 +62,8 @@ def next_page(self):
A new :class:`VumiIndexPage` object containing the next page of
results.
"""
if not self.has_next_page():
return None
try:
result = self._index_page.next_page()
except RiakError as e:
Expand Down
3 changes: 3 additions & 0 deletions vumi/persist/tests/test_model.py
Expand Up @@ -727,6 +727,9 @@ def test_index_keys_page(self):
self.assertEqual(sorted(keys3), [])
self.assertEqual(keys3.has_next_page(), False)

no_keys = yield keys3.next_page()
self.assertEqual(no_keys, None)

@Manager.calls_manager
def test_index_keys_page_explicit_continuation(self):
indexed_model = self.manager.proxy(IndexedModel)
Expand Down
4 changes: 3 additions & 1 deletion vumi/persist/txriak_manager.py
Expand Up @@ -7,7 +7,7 @@
from riak import RiakClient, RiakObject, RiakMapReduce, RiakError
from twisted.internet.threads import deferToThread
from twisted.internet.defer import (
inlineCallbacks, returnValue, gatherResults, maybeDeferred)
inlineCallbacks, returnValue, gatherResults, maybeDeferred, succeed)

from vumi.persist.model import Manager, VumiRiakError

Expand Down Expand Up @@ -69,6 +69,8 @@ def next_page(self):
A new :class:`VumiTxIndexPage` object containing the next page of
results.
"""
if not self.has_next_page():
return succeed(None)
d = deferToThread(self._index_page.next_page)
d.addCallback(type(self))
d.addErrback(riakErrorHandler)
Expand Down

0 comments on commit 86dd92c

Please sign in to comment.