Commits

Matt Chaput committed a1e588c

Raise ValueError if user calls Searcher.search_page() with too high pagenum.
Added ResultsPage.is_last_page() method.

  • Participants
  • Parent commits 58d1a57

Comments (0)

Files changed (1)

File src/whoosh/searching.py

             raise ValueError("pagenum must be >= 1")
         
         self.pagecount = int(ceil(self.total / pagelen))
-        if pagenum > self.pagecount:
-            pagenum = self.pagecount
+        if pagenum > 1 and pagenum > self.pagecount:
+            raise ValueError("Asked for page %s of %s" % (pagenum, self.pagecount))
         
         self.pagenum = pagenum
 
         page.
         """
         return self.results.scored_list[n + self.offset]
+    
+    def is_last_page(self):
+        """Returns True if this object represents the last page of results.
+        """
+        
+        return self.pagecount == 0 or self.pagenum == self.pagecount
 
 
 class Facets(object):