当前位置: 首页>>代码示例>>Python>>正文


Python Package.all方法代码示例

本文整理汇总了Python中models.package.Package.all方法的典型用法代码示例。如果您正苦于以下问题:Python Package.all方法的具体用法?Python Package.all怎么用?Python Package.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.package.Package的用法示例。


在下文中一共展示了Package.all方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: index

# 需要导入模块: from models.package import Package [as 别名]
# 或者: from models.package.Package import all [as 别名]
    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 = QueryPager(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 = QueryPager(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})
开发者ID:dart-lang,项目名称:pub-dartlang,代码行数:30,代码来源:packages.py

示例2: generate_feed

# 需要导入模块: from models.package import Package [as 别名]
# 或者: from models.package.Package import all [as 别名]
 def generate_feed(page=1):
     feed = FeedGenerator()
     feed.id("https://pub.dartlang.org/feed.atom")
     feed.title("Pub Packages for Dart")
     feed.link(href="https://pub.dartlang.org/", rel="alternate")
     feed.link(href="https://pub.dartlang.org/feed.atom", rel="self")
     feed.description("Last Updated Packages")
     feed.author({"name": "Dart Team"})
     i = 1
     pager = QueryPager(int(page), "/feed.atom?page=%d",
                        Package.all().order('-updated'),
                        per_page=10)
     for item in pager.get_items():
         i += 1
         entry = feed.add_entry()
         for author in item.latest_version.pubspec.authors:
             entry.author({"name": author[0]})
         entry.title("v" + item.latest_version.pubspec.get("version") +\
             " of " + item.name)
         entry.link(link={"href": item.url, "rel": "alternate",
             "title": item.name})
         entry.id(
             "https://pub.dartlang.org/packages/" + item.name + "#" +\
             item.latest_version.pubspec.get("version"))
         entry.description(
             item.latest_version.pubspec
             .get("description", "Not Available"))
         readme = item.latest_version.readme
         if not readme is None:
             entry.content(item.latest_version.readme.render(), type='html')
         else:
             entry.content("<p>No README Found</p>", type='html')
     return feed
开发者ID:d2m,项目名称:pub-dartlang,代码行数:35,代码来源:feed.py

示例3: index

# 需要导入模块: from models.package import Package [as 别名]
# 或者: from models.package.Package import all [as 别名]
    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}
        )
开发者ID:amouravski,项目名称:pub-dartlang,代码行数:15,代码来源:packages.py

示例4: index

# 需要导入模块: from models.package import Package [as 别名]
# 或者: from models.package.Package import all [as 别名]
    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 = QueryPager(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
        })
开发者ID:a14n,项目名称:pub-dartlang,代码行数:17,代码来源:packages.py

示例5: index

# 需要导入模块: from models.package import Package [as 别名]
# 或者: from models.package.Package import all [as 别名]
 def index(self):
     """Retrieves the front page of the package server."""
     packages = Package.all().order('-updated').fetch(5)
     return handlers.render('index', recent_packages=packages)
开发者ID:a14n,项目名称:pub-dartlang,代码行数:6,代码来源:root.py


注:本文中的models.package.Package.all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。