def get(self, path="/", *args, **kwargs):
self.response.headers['Content-Type'] = 'text/plain'
# Prevent Hash-collision attacks
assert len(self.request.arguments()) < 50
# Fill the (surprisingly empty) kwargs dict with named request params
tmpArgs = dict((k, self.request.get_all(k)) for k in self.request.arguments())
for key in tmpArgs.keys()[:]:
if len(tmpArgs[key]) == 0:
continue
if not key in kwargs.keys():
if len(tmpArgs[key]) == 1:
kwargs[key] = tmpArgs[key][0]
else:
kwargs[key] = tmpArgs[key]
else:
if isinstance(kwargs[key], list):
kwargs[key] = kwargs[key] + tmpArgs[key]
else:
kwargs[key] = [kwargs[key]] + tmpArgs[key]
del tmpArgs
if "self" in kwargs.keys(): # self is reserved for bound methods
raise NotImplementedError()
path = urlparse.urlparse(path).path
pathlist = [urlparse.unquote(x) for x in path.strip("/").split("/")]
if len(pathlist) < 2:
raise NotImplementedError()
tfunc = pathlist[1]
pathlist = pathlist[2:]
if tfunc == "exportDb":
self.response.write(self.exportDb(*pathlist, **kwargs))
elif tfunc == "exportBlob":
self.response.write(self.exportBlob(*pathlist, **kwargs))
elif tfunc == "download":
self.response.write(self.download(*pathlist, **kwargs))
elif tfunc == "info":
self.response.write(self.info(*pathlist, **kwargs))
elif tfunc == "listCursors":
self.response.write(self.listCursors(*pathlist, **kwargs))
elif tfunc == "listKinds":
self.response.write(self.listKinds(*pathlist, **kwargs))
elif tfunc == "_ah":
pass
else:
raise NotImplementedError()
评论列表
文章目录