def _call_meth(self, match_info, name):
# call meth with variable segments of the request as arguments.
meth = getattr(self, name)
if (not asyncio.iscoroutinefunction(meth) and
not inspect.isgeneratorfunction(meth)):
meth = asyncio.coroutine(meth)
# get variable segments for the current provider.
var = {k: v for k, v in match_info.items() if not k.startswith('_')}
# get method signature and apply variable segments
req, _, kw, _ = inspect.getargspec(getattr(meth, '__wrapped__', meth))
if kw is None:
rv = yield from meth(**{k: v for k, v in var.items() if k in req})
else:
rv = yield from meth(**var) # any kerword arguments is accepted
return rv
评论列表
文章目录