diff roundup/cgi/client.py @ 4943:7920d700e580 routing

Add support for extensions to provide custom pages to Roundup and update CHANGES.txt 1. Added registerHandler() extension point to instance.Tracker to register URL handlers for specific routes 2. Added processing of extension routes to client.cgi 3. Added example plugins/extensions/custompage.py
author anatoly techtonik <techtonik@gmail.com>
date Tue, 25 Nov 2014 17:29:38 +0300
parents 355ce349df42
children 01d14361cae7
line wrap: on
line diff
--- a/roundup/cgi/client.py	Tue Nov 25 15:58:14 2014 +0300
+++ b/roundup/cgi/client.py	Tue Nov 25 17:29:38 2014 +0300
@@ -351,14 +351,23 @@
         self.classname = None
         self.template = None
 
-        # routing maps URL requests to handlers by path component
+        # setup routing to map URL requests to handlers by path component
+        # [ ] this code is run on each request, but it doesn't have to
         self.urlmap = [
             'xmlrpc', self.handle_xmlrpc,
             '_file/(.*)',  self.serve_static_file,
             '@@file/(.*)', self.serve_static_file,
         ]
+        for route, handler in self.instance.web_handlers.iteritems():
+            # no nested lists are created here
+            self.urlmap += [route, self.wrap_handler(handler)]
         self.router = Router(self.urlmap)
 
+    def wrap_handler(self, function):
+        def wrapper():
+            self.write(function())
+        return wrapper
+
     def setTranslator(self, translator=None):
         """Replace the translation engine
 

Roundup Issue Tracker: http://roundup-tracker.org/