Exemplo n.º 1
0
 def getPage(self,objects,numsPerpage=20, total_count=100):
     try: page_num = int(self.args.get('page', '1'))
     except ValueError: page_num = 1 
     paginator = Paginator(objects, numsPerpage, total_count=total_count)
     try: page = paginator.page(page_num)
     except InvalidPage: raise HTTPError(404)
     if not page: raise HTTPError(404)
     return page
Exemplo n.º 2
0
 def getPage(self, objects, numsPerpage=8, total_count=0, page_name='page'):
     try:
         page_num = int(self.args.get(page_name, '1'))
     except ValueError:
         page_num = 1
     logger.info("[page_name]: %s" % page_name)
     logger.info("[page_name %s]: [page_num]: %s" % (page_name, self.args.get(page_name, '1')))
     logger.info("[page_num]: %s" % page_num)
     try:
         _total_count = total_count or objects.count()
     except Exception as e:
         _total_count = total_count or len(objects)
     paginator = Paginator(objects, numsPerpage, total_count=_total_count)
     try:
         page = paginator.page(page_num)
     except InvalidPage:
         raise HTTPError(404)
     if not page: raise HTTPError(404)
     return page
Exemplo n.º 3
0
 def getPage(self, objects, numsPerpage=8, total_count=0, page_name='page'):
     try:
         page_num = int(self.args.get(page_name, '1'))
     except ValueError:
         page_num = 1
     logger.info("[page_name]: %s" % page_name)
     logger.info("[page_name %s]: [page_num]: %s" %
                 (page_name, self.args.get(page_name, '1')))
     logger.info("[page_num]: %s" % page_num)
     try:
         _total_count = total_count or objects.count()
     except Exception as e:
         _total_count = total_count or len(objects)
     paginator = Paginator(objects, numsPerpage, total_count=_total_count)
     try:
         page = paginator.page(page_num)
     except InvalidPage:
         raise HTTPError(404)
     if not page: raise HTTPError(404)
     return page