本文整理汇总了Python中Resource.get_backend方法的典型用法代码示例。如果您正苦于以下问题:Python Resource.get_backend方法的具体用法?Python Resource.get_backend怎么用?Python Resource.get_backend使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Resource
的用法示例。
在下文中一共展示了Resource.get_backend方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import Resource [as 别名]
# 或者: from Resource import get_backend [as 别名]
def __init__(self, request, prepcache=True):
"Determine and open cache location, get descriptor backend. "
super(CachingProtocol, self).__init__()
self.request = request
# Track server response
self.__status, self.__message = None, None
if not prepcache:
return
self.cache = Resource.get_cache(request.hostinfo, request.envelope[1])
# Get descriptor storage reference
self.descriptors = Resource.get_backend()
示例2: serve_descriptor
# 需要导入模块: import Resource [as 别名]
# 或者: from Resource import get_backend [as 别名]
def serve_descriptor(self, status, protocol, request):
q = urlparse.urlparse( request.url[3] )[4]
url = urlparse.urlparse(urllib.unquote(q[4:]))
if ':' in url[1]:
hostinfo = url[1].split(':')
hostinfo[1] = int(hostinfo[1])
else:
hostinfo = url[1], 80
cache = Resource.get_cache(hostinfo, url[2][1:])
descriptors = Resource.get_backend()
if cache.path in descriptors:
descr = descriptors[cache.path]
self.prepare_response(status,
Params.json_write(descr),
mime='application/json')
else:
self.prepare_response("404 No Data", "No data for %s %s %s %s"%request.url)