[mod_python] Newbie question: setting all calls to a certain directory to beprocessed by a script

john spurling synec at viscous.org
Wed Aug 27 18:31:58 EST 2003


On Wed, Aug 27, 2003 at 08:17:13PM -0500, Simon Willison wrote:
> Simon Willison wrote:
> >Ideally, I would like to 
> >set up a rule so that any requests for files that do NOT end in .jpg, 
> >.js, .gif or .css are handed off to the handle() function in the file of 
> >my choice. If that isn't possible, I'd like to set it up so that all 
> >requests within the directory in which my .htaccess file lives are 
> >handled by the one handle() function.
> 
> Well, I've worked out the second option. My .htaccess file now looks 
> like this:
> 
> SetHandler python-program
> PythonHandler handler
> PythonDebug On

good show. using this setting, try this handler:

from mod_python import apache
_types_to_skip = ['jpg', 'gif', 'png']
def handler(req):
    try:
    file_extention = req.uri.split('.')[-1].lower()
    if file_extention in _types_to_skip:
        return apache.DECLINED
    except:
        pass

this will tell apache to go on to another handler for requests ending
in any of the above extensions.

let us know if you have further questions.

-john

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mailman.modpython.org/pipermail/mod_python/attachments/20030827/62e64362/attachment-0003.bin


More information about the Mod_python mailing list