On 18Jan2022 08:43, Paul Bryan <pbr...@anode.ca> wrote:
>+1
>
>"x-" prefix indicates ad hoc (unofficial), not deprecated.
>
>I agree, an official MIME type should be preferred over an unofficial
>one. 

Maybe, but I disagree about the proposed solution. There are 
circumstances where you want a specific MIME type guess, and the best 
way to do that is the apply a specific ordering to your mime.types file 
so that the desired type comes first, and is found first.

And looking at milahu's example, that's exactly what was there:

    application/javascript        js
    application/x-javascript      js

It would be reasonable and generally desireable to take the first one.

The problem with saying "oh, let's examine the types and exclude or 
deprioritise the ones we don't like such as x-*" as that removes control 
from the user (the caller of mimetypes.guess_type() and the author of 
/etc/mime.types). It embeds fixed policy _inside_ mimetypes.guess_type() 
where it can't be turned off without growing a heap of weird mode flags.

The better fix it to honour the order of the mime.types file as 
_expressing_ policy, which is what the OP already has - they just don't 
have guess_type() doing it that way.

Arguments for embedding _policy_ inside guess_type() will be met with my 
standard example: the ancient Netscape proxy config had regexp based 
redirect rules, not uncommon. But Netscape prioritised these by the 
length of the regexp instead of the config file ordering. Insanity 
abounded with regexp wackiness purely to make some rules longer than 
others.

Cheers,
Cameron Simpson <c...@cskk.id.au>
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/4P6G7WKRZR5GR2ZLRGO5QI3OCH7SEVVI/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to