RE: [Zope] application/octet-stream vs. application/msword
Hi Dieter & all > The problem is, currently, not interesting enough for > me to analyse is seriously. I can well understand, I wish I could forget about it :( > If you know, that you add only "*.doc" files I add .doc, .zip, .exe (self-extracting zip), .pdf and .ppt ... so the quick and dirty route won't save me this time .. Thanks for your time till now! -- jean ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
RE: [Zope] application/octet-stream vs. application/msword
Jean Jordaan writes: > > 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: > > > Add a document. > > The initial method of 'ccDocClass_factory' is 'ccDocClass_addForm', > and that form's action is 'ccDocClass_add' which eventually calls: > > The problem is, currently, not interesting enough for me to analyse is seriously. This may change, when some day, I or a collegue runs against strange content type assignment. If you know, that you add only "*.doc" files in your "ccDocClass_add, why not add explicitely "content_type='application/msword'", i.e. Dieter ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
RE: [Zope] application/octet-stream vs. application/msword
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: Add a document. The initial method of 'ccDocClass_factory' is 'ccDocClass_addForm', and that form's action is 'ccDocClass_add' which eventually calls: 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 ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] application/octet-stream vs. application/msword
Jean Jordaan writes: > How does Zope recognize the type of a file? It uses "OFS.content_types.guess_content_type" (look at the source in OFS/Image.py), unless the manage_addFile specifies an explicit "content_type". > Can Zope be taught more types? Look at the source of "OFS.content_types". Dieter ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] application/octet-stream vs. application/msword
Jean Jordaan wrote: > > Hi Zopers > > How does Zope recognize the type of a file? Mostly it > recognizes .doc's correctly as 'application/msword', but > sometimes they turn up as 'application/octet-stream'. > Others, like .fh8 (Freehand) and .exe (self-extracting > zip) are (unsurprisingly) also turning up as > 'application/octet-stream'. > > The files are being added using > > > Can Zope be taught more types? Failing that, I guess I > should try to catch the extension using > "find(S, SUB[, START])" on the id (which is the filename). When you say understand filetypes, Zope just looks at the xtension and matches it to some known file types. you can add any custom mappings you need to the content_types.py file in the OFS dir. these functions get called for identifying file types. Cheers Kapil ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )