def get_page_data(self,query,page_size=None,page=None): if not page_size: page_size = int(self.get_argument("page_size",50)) if not page: page = int(self.get_argument("page", 1)) page = int(page) offset = (page - 1) * page_size result = query.limit(page_size).offset(offset) page_data = Paginator(self.get_page_url, page, query.count(), page_size) page_data.result = result return page_data
def get_page_data(self, query): """ 获取分页数据 """ page_size = int(self.get_argument("page_size",30)) page = int(self.get_argument("page", 1)) if page<=0: page=1 offset = (page - 1) * page_size #从数据库查询数据的起始位置 result = query.limit(page_size).offset(offset) page_data = Paginator(self.get_page_url, page, query.count(), page_size) page_data.result = result return page_data