[mod_python] setting content_type intelligently

Manfred Stienstra manfred.stienstra at dwerg.net
Tue Jan 13 17:50:57 EST 2004


On Tue, 2004-01-13 at 16:40, Daniel J. Popowich wrote:
>    1.  What does mod_python/apache do if content_type is not set by a
>        handler?  Does it default to text/plain?

It defaults to the default Apache mimetype.

>    2.  I'm looking for an intelligent means of setting the
>        content_type.  I know I can use mimetypes.guess_type(), but
>        that is based only on the file's extension.  Apache does more
>        than that, eg, if 'foo.gif' was named 'foo' apache still
>        determines the content type correctly as image/gif.  Is there a
>        way to tap into apache's content_type determination?

Apache uses the same resolution as the 'file' command on *nix, it uses a
file with rules (/etc/apache*/mime.types) to resolve the mimetype. I'm
not sure if there is a python frontend for this.

Manfred



More information about the Mod_python mailing list