Message143665
I'm running into a similar issue with this function. My bug is that get_type('foo.png') returns image/x-png. This occurs on windows because there are mappings to both image/png and image/x-png in the registry (as there should be, since that key is actually a reverse mapping) and the code simply picks the first key that it enumerates over. This issue strikes in both directions.
Chris and others bring up a valid issue: how to decide what the winning result is?
I think the answer is pretty clear - you use the common_types mapping already in the file and expand it as appropriate. If the mimetype can't be found, only then do you go to the windows registry. The behavior on Linux is even stranger to me (now we'll dig through an arbitrary list of files that might contain MIME info or may have completely irrelevant data) but it's a pragmatic solution.
If someone needs to customize what guess_type returns, they can simply wrap the guess_type function in their own code or monkey patch if they don't have access to the source they're running. Changing such a mime type is a really advanced and unusual operation. If that's unacceptable, the code can provide a hook for an 'apache MIME config' file on windows in a standard place (either pythonpath, or %system% or wherever) that it will check before going to common_types or to the registry.
Making this change doesn't require changing the API at all, just the implementation changes. |
|
Date |
User |
Action |
Args |
2011-09-07 08:20:07 | leos | set | recipients:
+ leos, jlgijsbers, josiahcarlson, kxroberto, ajaksu2, eric.araujo, lambacck, skrah, ptarjan, sandro.tosi, BreamoreBoy, elesbom |
2011-09-07 08:20:06 | leos | set | messageid: <1315383606.92.0.396032998607.issue1043134@psf.upfronthosting.co.za> |
2011-09-07 08:20:06 | leos | link | issue1043134 messages |
2011-09-07 08:20:05 | leos | create | |
|