本文整理匯總了Python中Resource.get_cache方法的典型用法代碼示例。如果您正苦於以下問題:Python Resource.get_cache方法的具體用法?Python Resource.get_cache怎麽用?Python Resource.get_cache使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Resource
的用法示例。
在下文中一共展示了Resource.get_cache方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: import Resource [as 別名]
# 或者: from Resource import get_cache [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_cache [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)