def repo_index(self, *tokens, **params):
"""Generate a page showing the list of repositories served by
this Apache instance."""
self.setup(cherrypy.request)
# In order to reuse the pkg.depotd shtml files, we need to use
# the pkg.server.api, which means passing a DepotBUI object,
# despite the fact that we're not serving content for any one
# repository. For the purposes of rendering this page, we'll
# use the first object we come across.
depot = depot_buis[list(depot_buis.keys())[0]]
accept_lang = self.get_accept_lang(cherrypy.request, depot)
cherrypy.request.path_info = "/{0}".format(accept_lang)
tlookup = mako.lookup.TemplateLookup(
directories=[depot.web_root])
pub = None
base = pkg.server.api.BaseInterface(cherrypy.request, depot,
pub)
# build a list of all repositories URIs and BUI links,
# and a dictionary of publishers for each repository URI
repo_list = []
repo_pubs = {}
for repo_prefix in repositories.keys():
repo = repositories[repo_prefix]
depot = depot_buis[repo_prefix]
repo_url = "{0}/{1}".format(cherrypy.request.base,
repo_prefix)
bui_link = "{0}/{1}/index.shtml".format(
repo_prefix, accept_lang)
repo_list.append((repo_url, bui_link))
repo_pubs[repo_url] = \
[(pub, "{0}/{1}/{2}".format(
cherrypy.request.base, repo_prefix,
pub)) for pub in repo.publishers]
repo_list.sort()
template = tlookup.get_template("repos.shtml")
# Starting in CherryPy 3.2, cherrypy.response.body only allows
# bytes.
return misc.force_bytes(template.render(g_vars={"base": base,
"pub": None, "http_depot": "true", "lang": accept_lang,
"repo_list": repo_list, "repo_pubs": repo_pubs
}))
评论列表
文章目录