[Zope] application/octet-stream vs. application/msword

Jean Jordaan Jean@mosaicsoftware.com
Fri, 11 Aug 2000 13:59:45 +0200


Hi Dieter & all

> > How does Zope recognize the type of a file?
> It uses "OFS.content_types.guess_content_type" 

OK, so 'manage_addFile' uses 'guess_content_type'?

I'm a bit confused here .. I see three lists of content
types, excerpted below. They are in:

  1. 'lib/python/OFS/content_types.py'

  2. 'bin/lib/mimetypes.py' and

  3. 'ZServer/medusa/mime_type_tabel.py'

There is some overlap between the lists (eg. '.doc' occurs
in 1 and in 3, and '.cdf' occurs in all three). What relation
is there between the lists? 

The other thing I'm wondering is, it looks as if '.doc' should
*always* be recognized as msword. How could it sometimes turn up
as octet-stream? To add documents I call:

  <a href="manage_addProduct/ccDoc/ccDocClass_factory">
  Add a document.</a>

The initial method of 'ccDocClass_factory' is 'ccDocClass_addForm',
and that form's action is 'ccDocClass_add' which eventually calls:

  <dtml-call "manage_addFile('', file, '')">

So how come '.doc's get added as application/octet-stream ?

Excerpts:
---------

In 'lib/python/OFS/content_types.py' I find:

........................................................
# This gives us a hook to add content types that
# aren't currently listed in the mimetypes module.
_addtypes=(
    ('.cdf', 'application-x-cdf'),
    ('.doc', 'application/msword'),
[...]
    ('.xul', 'text/xul'),
    )
........................................................

and in 'bin/lib/mimetypes.py' I find:

........................................................
types_map = {
[...]
    '.bcpio': 'application/x-bcpio',
    '.bin': 'application/octet-stream',
    '.cdf': 'application/x-netcdf',
    '.cpio': 'application/x-cpio',
    '.csh': 'application/x-csh',
[...]
    '.zip': 'application/zip',
    }
........................................................

and, finally, in 'ZServer/medusa/mime_type_tabel.py' I find:

........................................................
# Converted by ./convert_mime_type_table.py from:
# /usr/src2/apache_1.2b6/conf/mime.types
#
content_type_map = \
  {
[...]
       'cdf':  'application/x-netcdf',
[...]
       'doc':  'application/msword',
[...]
       'zip':  'application/zip',
  }
........................................................

-- 
jean