Mercurial > p > roundup > code
diff roundup/cgi/client.py @ 4918:35dc9191394d routing
routing: Use Router in cgi.client.main
| author | anatoly techtonik <techtonik@gmail.com> |
|---|---|
| date | Tue, 12 Aug 2014 00:36:15 +0300 |
| parents | 92757447dcf0 |
| children | 91029cc0dc59 |
line wrap: on
line diff
--- a/roundup/cgi/client.py Mon Aug 11 18:31:49 2014 +0300 +++ b/roundup/cgi/client.py Tue Aug 12 00:36:15 2014 +0300 @@ -22,6 +22,9 @@ from roundup.cgi import accept_language from roundup import xmlrpc +# new namespace for universal web components +from roundup.web.router import Router + from roundup.anypy.cookie_ import CookieError, BaseCookie, SimpleCookie, \ get_cookie_date from roundup.anypy.io_ import StringIO @@ -348,6 +351,12 @@ self.classname = None self.template = None + # routing maps URL requests to handlers by path component + self.urlmap = [ + 'xmlrpc', self.handle_xmlrpc, + ] + self.router = Router(self.urlmap) + def setTranslator(self, translator=None): """Replace the translation engine @@ -369,9 +378,10 @@ def main(self): """ Wrap the real main in a try/finally so we always close off the db. """ + handler, params = self.router.get_handler(self.path) try: - if self.env.get('CONTENT_TYPE') == 'text/xml' and self.path == 'xmlrpc': - self.handle_xmlrpc() + if handler: + handler() else: self.inner_main() finally:
