def dispatch_request(self, request):
"""
????~????
request.environ -> url_map bind to environ ->
caller(???) -> ins(??????) -> current_method(????http??)
-> current_method(ins): ??????????????? -> res(????)
-> make_response(??????????)
?????????????????
"""
adapter = self.url_map.bind_to_environ(request.environ)
try:
endpoint, values = adapter.match()
caller = [
caller_rule[0] for caller_rule in \
self.url_map._caller_rule \
if endpoint == caller_rule[0].__name__
][0]
ins = caller(app_name=self.app_name, **values)
methods = adapter.default_method
current_method = getattr(caller, request.method.lower(), None)
if not current_method:
return self.make_response("Method not allowed")
res = current_method(ins)
return self.make_response(res, request) or \
self.make_response("rv is NoneType...")
except NotFound, e:
return self.error_404()
except HTTPException, e:
return e
评论列表
文章目录