本文整理汇总了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})
示例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
示例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}
)
示例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
})
示例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)