Ejemplo n.º 1
0
    def index(self, page=1, format='html'):
        """Retrieve a paginated list of uploaded packages.

        Arguments:
          page: The page of packages to get. Each page contains 10 packages.
        """
        if format == 'json':
            pager = Pager(int(page), "/packages.json?page=%d",
                          Package.all().order('-updated'),
                          per_page=50)
            return json.dumps({
                "packages": [
                    handlers.request().url(action='show', id=package.name)
                    for package in pager.get_items()
                ],
                "prev": pager.prev_url,
                "next": pager.next_url,
                "pages": pager.page_count
            })
        else:
            pager = Pager(int(page), "/packages?page=%d",
                          Package.all().order('-updated'))
            title = 'All Packages'
            if page != 1: title = 'Page %s | %s' % (page, title)
            return handlers.render("packages/index",
                                   packages=pager.get_items(),
                                   pagination=pager.render_pagination(),
                                   layout={'title': title})
Ejemplo n.º 2
0
    def index(self, page=1, format='html'):
        """Retrieve a paginated list of uploaded packages.

        Arguments:
          page: The page of packages to get. Each page contains 10 packages.
        """
        if format == 'json':
            pager = Pager(int(page),
                          "/packages.json?page=%d",
                          Package.all().order('-updated'),
                          per_page=50)
            return json.dumps({
                "packages": [
                    handlers.request().url(action='show', id=package.name)
                    for package in pager.get_items()
                ],
                "prev":
                pager.prev_url,
                "next":
                pager.next_url,
                "pages":
                pager.page_count
            })
        else:
            pager = Pager(int(page), "/packages?page=%d",
                          Package.all().order('-updated'))
            title = 'All Packages'
            if page != 1: title = 'Page %s | %s' % (page, title)
            return handlers.render("packages/index",
                                   packages=pager.get_items(),
                                   pagination=pager.render_pagination(),
                                   layout={'title': title})
Ejemplo n.º 3
0
    def index(self, page=1):
        """Retrieve a paginated list of uploaded packages.

        Arguments:
          page: The page of packages to get. Each page contains 10 packages.
        """
        pager = Pager(int(page), "/packages?page=%d", Package.all().order("-updated"))
        title = "All Packages"
        if page != 1:
            title = "Page %s | %s" % (page, title)
        return handlers.render(
            "packages/index", packages=pager.get_items(), pagination=pager.render_pagination(), layout={"title": title}
        )
Ejemplo n.º 4
0
    def index(self, page=1):
        """Retrieve a paginated list of uploaded packages.

        Arguments:
          page: The page of packages to get. Each page contains 50 packages.
        """
        pager = Pager(int(page), "/api/packages?page=%d",
                      Package.all().order('-updated'),
                      per_page=100)
        return json.dumps({
            "packages": [package.as_dict() for package in pager.get_items()],
            "prev_url": pager.prev_url,
            "next_url": pager.next_url,
            "pages": pager.page_count
        })