[Web-SIG] Accessing deeply nested multiple doc roots for WSGI apps

Ian Bicking ianb at colorstudy.com
Sun Oct 23 03:02:08 CEST 2005


Ben Bangert wrote:
> As I'm working on some tools to facilitate the easy use and  
> distribution of WSGI apps and middleware, a problem is starting to  
> crop up. Most of these WSGI apps come with their own little set of  
> static files (images, javascript, etc.) that need to be delivered  
> should they be executed. Of course, Apache and such only allow for a  
> single doc-root so I can't exactly through in each WSGI app's path to  
> the static files.
> 
> These static paths are also very deep as the WSGI apps are installed  
> as Python egg's. I've been using Ian's StaticURLParser from Python  
> Paste, but its speed concerns me plus the fact that it means my  
> webapp is essentially doing little more than relay filesystem data.
> 
> Several thoughts occur to me to deal with this:
> 
> 1) Have a faster version of StaticURLParser, perhaps written in C
> 2) Create some sort of specification for a single static docroot  
> where each WSGI egg gets its own symlink into

I've thought about this too.  I think a little of both is best -- have
some configurable location where files can be dumped (using
Package/Version/) and a URL that goes with that.  Then I figure the
application, on first startup, will either copy or symlink files into
that location -- though sometimes the user the application runs as
couldn't do that, so maybe there should be a way to make it happen
separately from running the application.  In fact, maybe it could simply
be some seperate piece of metadata, so the application doesn't have to
do it at all.

Then the app should generate all the URLs based on that configured
static location, or if no location has been configured it should fall
back on StaticURLParser.  The fallback is useful, especially in a
situation like a standalone HTTP server where there isn't any static
serving (or at least none that is particularly better than StaticURLParser).

-- 
Ian Bicking  |  ianb at colorstudy.com  |  http://blog.ianbicking.org


More information about the Web-SIG mailing list