def open_0(self, *tokens):
"""Starts a transaction for the package name specified in the
request path. Returns no output."""
request = cherrypy.request
response = cherrypy.response
client_release = request.headers.get("Client-Release", None)
try:
pfmri = tokens[0]
except IndexError:
pfmri = None
# XXX Authentication will be handled by virtue of possessing a
# signed certificate (or a more elaborate system).
if not pfmri:
raise cherrypy.HTTPError(http_client.BAD_REQUEST,
_("A valid package FMRI must be specified."))
try:
pfmri = fmri.PkgFmri(pfmri, client_release)
trans_id = self.repo.open(client_release, pfmri)
except (fmri.FmriError, srepo.RepositoryError) as e:
# Assume a bad request was made. A 404 can't be
# returned here as misc.versioned_urlopen will interpret
# that to mean that the server doesn't support this
# operation.
cherrypy.log("Request failed: {0}".format(e))
raise cherrypy.HTTPError(http_client.BAD_REQUEST, str(e))
if pfmri.publisher and not self._get_req_pub():
self.__map_pub_ops(pfmri.publisher)
# Set response headers before returning.
response.headers["Content-type"] = "text/plain; charset=utf-8"
response.headers["Transaction-ID"] = trans_id
评论列表
文章目录