[mod_python] How to make a handler for static files?

Scott Chapman scott_list at mischko.com
Mon Feb 27 03:24:05 EST 2006


Hi all!

I want to make a funky hander for static files.  It should return the requested 
static file if it's in the directory requested.  If it's not there, it should 
move up a directory and try there.

I'm not sure how to make a static file handler that simply returns the file. 
Does the handler have to set a Content Type that is specific to each type of 
file or will the browser figure things out without this?  I'm interested only in 
css, images, and javascript files in this context currently but I may need to 
expand it later.  Is there any sample of a straight forward static file handler 
around?

Why am I trying to do this weird thing?  I am experimenting with setting up a 
web server with no virtual servers (only a default server) that handles many 
domains with one uberservlet.  I want to make it so that each site can use it's 
own javascript stuff but if it's not in the /js/site directory, I want it to 
look in /js, same for css files (/css/site up to /css), etc.

This setup would also affect logging. All sites would be logged in one file for 
access and one for errors, rather than separate files for each virtual.  I'd 
need to have the site's internal name or perhaps the full site name 
(foo.domain.com) logged in each line of the log file.  Any clues on how to set 
this up would be appreciated also.

Why would I want to experiment with a thing like this?  I want to be able to add 
virtual servers to my site without having to restart Apache and I want to 
further centralize things.

Any help would be greatly appreciated!
Scott

-- 
q: Why do so many people take an instant dislike to MySQL and PHP?
a: It saves time.
ps: Use PostgreSQL and Python instead.


More information about the Mod_python mailing list