docs: def apply_pagination(self, q):
          """
          Filters the query so that a given page is returned. The record count
          must be set in advance.
          :param q: Query to be paged.
          :return: Paged query.
          """
          # type: (Query)->Query
          assert self.record_count >= 0, "Record count must be set."
          return q.limit(self.page_size).offset(self.offset)