summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSatoshi Kobayashi <satoshi-k@stratosphere.co.jp>2013-10-07 17:41:35 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2013-10-08 07:53:48 +0900
commitb9c1fdb0d8e660ae31c2b66f1041e0570699b71a (patch)
treeb4fe44a05f8310f80e5ea9857c2701b9a2ebca16
parent789fbb3a519ea52c771f3877bcc5d48439f78a7c (diff)
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 <satoshi-k@stratosphere.co.jp> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/app/wsgi.py19
1 files changed, 18 insertions, 1 deletions
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()