From b9c1fdb0d8e660ae31c2b66f1041e0570699b71a Mon Sep 17 00:00:00 2001 From: Satoshi Kobayashi Date: Mon, 7 Oct 2013 17:41:35 +0900 Subject: Switch how to call the API of Routes for every version The parameter of the API of Routes differs between 1.13 and 1.10. Routes 1.10 is provided by base repository of RHEL. Signed-off-by: Satoshi Kobayashi Signed-off-by: FUJITA Tomonori --- ryu/app/wsgi.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/ryu/app/wsgi.py b/ryu/app/wsgi.py index ff3ef6ac..80698c08 100644 --- a/ryu/app/wsgi.py +++ b/ryu/app/wsgi.py @@ -74,10 +74,27 @@ class WSGIApplication(object): self.mapper = Mapper() self.registory = {} 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 @webob.dec.wsgify def __call__(self, req): - match = self.mapper.match(environ=req.environ) + match = self._match(req) if not match: return webob.exc.HTTPNotFound() -- cgit v1.2.3