Re: [Zope-dev] Re: inconsistent mimetype assignment for uploaded files
Dominic Hiles wrote:
Sorry, I missed these susbequent follow-ups before posting a reply a few minutes ago! If we're going down this route, can we at least change things so that the "guessing" is done using ZServer.medusa.mime_type_table, rather than the default python mimetypes table?
I would guess that the medusa version is more neglected than the Python one; is your experience otherwise? Tres. -- =============================================================== Tres Seaver tseaver@zope.com Zope Corporation "Zope Dealers" http://www.zope.com
Dear Tres, --On 04 October 2004 13:43 -0400 Tres Seaver <tseaver@zope.com> wrote:
Dominic Hiles wrote:
Sorry, I missed these susbequent follow-ups before posting a reply a few minutes ago! If we're going down this route, can we at least change things so that the "guessing" is done using ZServer.medusa.mime_type_table, rather than the default python mimetypes table?
I would guess that the medusa version is more neglected than the Python one; is your experience otherwise?
I now realise where my confusion came from. Python 2.1.3 had only 85 file extensions listed in mimetypes.types_map.keys() whereas ZServer.medus.mime_types_table showed 106 with Zope 2.6.4. However, Python 2.3.3 is now up to 117, so I guess it makes the better choice. Apologies for the noise....that said, I'm still unhappy that a browser can dictate the mimetype chosen for an uploaded file, but I'm happy enough to fix that at the application level. Cheers, Dominic
Hi, On Tue, 2004-10-05 at 12:11, Dominic Hiles wrote:
Dear Tres,
--On 04 October 2004 13:43 -0400 Tres Seaver <tseaver@zope.com> wrote:
Dominic Hiles wrote:
Sorry, I missed these susbequent follow-ups before posting a reply a few minutes ago! If we're going down this route, can we at least change things so that the "guessing" is done using ZServer.medusa.mime_type_table, rather than the default python mimetypes table?
I would guess that the medusa version is more neglected than the Python one; is your experience otherwise?
I now realise where my confusion came from. Python 2.1.3 had only 85 file extensions listed in mimetypes.types_map.keys() whereas ZServer.medus.mime_types_table showed 106 with Zope 2.6.4. However, Python 2.3.3 is now up to 117, so I guess it makes the better choice. Apologies for the noise....that said, I'm still unhappy that a browser can dictate the mimetype chosen for an uploaded file, but I'm happy enough to fix that at the application level.
Well, the problem might be the asymptation part of the filename should be considered an indicator of its contents. Arent there any libs for python to examine the contents (usually the first few bytes) for the type of the file? Regards Tino
On Tue, 05 Oct 2004 12:44:32 +0200, Tino Wildenhain <tino@wildenhain.de> wrote:
Well, the problem might be the asymptation part of the filename should be considered an indicator of its contents.
That is a nuissance. It's unfortunate we still don't have any sort of common type system for bytestreams that's supported in filesystems. But disk files aren't the only source of bytestreams, so that doesn't necessarily help us in the end.
Arent there any libs for python to examine the contents (usually the first few bytes) for the type of the file?
I'm not aware of any for the general case. There are a few things like the imghdr module, but those are not for arbitrary files, and likely aren't sufficiently capable. I think there's a library from the Gnome desktop project for this (basically providing something like the Unix "file" command), but I don't know if there's a Python wrapper for the library, or an all-Python re-implementation. -Fred -- Fred L. Drake, Jr. <fdrake at gmail.com> Zope Corporation
i believe you were referring to http://freedesktop.org/Software/shared-mime-info spec http://freedesktop.org/Standards/shared-mime-info-spec its a system wide shared mime database for use by applications (ie. both gnome and kde). apparently no python bindings. -kapil On Tue, 2004-10-05 at 10:42 -0400, Fred Drake wrote:
?
I think there's a library from the Gnome desktop project for this (basically providing something like the Unix "file" command), but I don't know if there's a Python wrapper for the library, or an all-Python re-implementation.
-Fred
Em Ter, 2004-10-12 às 00:23, Kapil Thangavelu escreveu:
i believe you were referring to http://freedesktop.org/Software/shared-mime-info
spec http://freedesktop.org/Standards/shared-mime-info-spec
its a system wide shared mime database for use by applications (ie. both gnome and kde). apparently no python bindings.
Actually, the last url above lists a certain ROX-Lib: http://rox.sourceforge.net/phpwiki/index.php/ROX-Lib It's pure Python and suports a lot of stuff besides mime, but seems to require gtk, which could be a problem for people wanting to maintain slim servers free of any X Window System client dependencies. It's certainly too heavy a dependency for Zope :-) Cheers, Leo
participants (6)
-
Dominic Hiles -
Fred Drake -
Kapil Thangavelu -
Leonardo Rochael Almeida -
Tino Wildenhain -
Tres Seaver