def _get_req_pub(self):
"""Private helper function to retrieve the publisher prefix
for the current operation from the request path. Returns None
if a publisher prefix was not found in the request path. The
publisher is assumed to be the first component of the path_info
string if it doesn't match the operation's name. This does mean
that a publisher can't be named the same as an operation, but
that isn't viewed as an unreasonable limitation.
"""
if self.request_pub_func:
return self.request_pub_func(cherrypy.request.path_info)
try:
req_pub = cherrypy.request.path_info.strip("/").split(
"/")[0]
except IndexError:
return None
if req_pub not in self.REPO_OPS_DEFAULT and req_pub != "feed":
# Assume that if the first component of the request path
# doesn't match a known operation that it's a publisher
# prefix.
return req_pub
return None
评论列表
文章目录