diff options
author | IWASE Yusuke <iwase.yusuke0@gmail.com> | 2016-11-09 14:17:15 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-11-14 18:14:34 +0900 |
commit | 9f0461245972f15138bbe074fa836a8eb6662f37 (patch) | |
tree | 7193e65dd47df4688e4b0250fc97854d03f03ff5 | |
parent | 99ebbcce0e72f2a6b52f3d0190287747409d105b (diff) |
wsgi: Avoid using inspect.getargspec
Officially, "inspect.getargspec" is obsoleted in Python 3.0,
this patch fixes to avoid using this function.
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/app/wsgi.py | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/ryu/app/wsgi.py b/ryu/app/wsgi.py index 1e19fed0..7d7f1306 100644 --- a/ryu/app/wsgi.py +++ b/ryu/app/wsgi.py @@ -225,23 +225,15 @@ class WSGIApplication(object): self.registory = {} self._wsmanager = WebSocketManager() super(WSGIApplication, self).__init__() - # XXX: Switch how to call the API of Routes for every version - match_argspec = inspect.getargspec(self.mapper.match) - if 'environ' in match_argspec.args: - # New API - self._match = self._match_with_environ - else: - # Old API - self._match = self._match_with_path_info - - def _match_with_environ(self, req): - match = self.mapper.match(environ=req.environ) - return match - - def _match_with_path_info(self, req): - self.mapper.environ = req.environ - match = self.mapper.match(req.path_info) - return match + + def _match(self, req): + # Note: Invoke the new API, first. If the arguments unmatched, + # invoke the old API. + try: + return self.mapper.match(environ=req.environ) + except TypeError: + self.mapper.environ = req.environ + return self.mapper.match(req.path_info) @wsgify_hack def __call__(self, req, start_response): |