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

Simon Willison cs1spw at bath.ac.uk
Wed Aug 27 21:15:27 EST 2003

john spurling wrote:
> 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

Fantastic. The apache.DECLINED bit is what I was missing. It even does a 
proper 404 error now if the requested image file isn't found.

Thanks for the prompt reply!

Simon Willison

More information about the Mod_python mailing list