Mercurial > p > roundup > code
diff roundup/cgi/client.py @ 4926:355ce349df42 routing
routing: Serve static files through proper routing in main()
instead of exception in determine_context()
| author | anatoly techtonik <techtonik@gmail.com> |
|---|---|
| date | Wed, 20 Aug 2014 13:43:22 +0300 |
| parents | 91029cc0dc59 |
| children | 7920d700e580 |
line wrap: on
line diff
--- a/roundup/cgi/client.py Wed Aug 20 13:37:34 2014 +0300 +++ b/roundup/cgi/client.py Wed Aug 20 13:43:22 2014 +0300 @@ -354,6 +354,8 @@ # routing maps URL requests to handlers by path component self.urlmap = [ 'xmlrpc', self.handle_xmlrpc, + '_file/(.*)', self.serve_static_file, + '@@file/(.*)', self.serve_static_file, ] self.router = Router(self.urlmap) @@ -381,7 +383,7 @@ handler, params = self.router.get_handler(self.path) try: if handler: - handler() + handler(*params) else: self.inner_main() finally: @@ -449,8 +451,8 @@ - HTTP Redirect (generally raised by an action) - SendFile (generally raised by determine_context) serve up a FileClass "content" property - - SendStaticFile (generally raised by determine_context) - serve up a file from the tracker "html" directory + - SendStaticFile (may be raised by an action) + serve up a file from static or template directory - Unauthorised (generally raised by an action) the action is cancelled, the request is rendered and an error message is displayed indicating that permission was not @@ -852,10 +854,6 @@ is generally only one entry long. - if there is no path, then we are in the "home" context. - - if the path is "_file", then the additional path entry - specifies the filename of a static file we're to serve up - from the instance "html" directory. Raises a SendStaticFile - exception.(*) - if there is something in the path (eg "issue"), it identifies the tracker class we're to display. - if the path is an item designator (eg "issue123"), then we're @@ -917,8 +915,6 @@ else: self.template = '' return - elif path[0] in ('_file', '@@file'): - raise SendStaticFile(os.path.join(*path[1:])) else: self.classname = path[0] if len(path) > 1: @@ -1022,9 +1018,8 @@ self._serve_file(lmt, mime_type, content, filename) def serve_static_file(self, file): - """ Serve up the file named from the templates dir + """ Send file from STATIC_FILES or TEMPLATES dir """ - # figure the filename - try STATIC_FILES, then TEMPLATES dir for dir_option in ('STATIC_FILES', 'TEMPLATES'): prefix = self.instance.config[dir_option] if not prefix:
