Tres Seaver wrote:

> Thomas Lotze wrote:
>> Following up to Martijn's observations on the ZTK, I'd like to propose a
>> clean-up of how we handle content types. There are several unrelated
>> pieces of code concerned with content types, these include at least
>> zope.contenttype, zope.mimetype and zope.publisher.contenttype.
>> 
>> - zope.contenttype does some content-type guessing from file names. It's
>>   just a few lines of code and comes with a table of some 30
>>   associations of file-name extensions with content types.
>> 
>> - zope.mimetype is a more substantial package that deals with
>>   content-type specific marker interfaces.

I actually forgot to mention that zope.mimetype comes with another table
associating content types with file name suffixes and other information.
It would certainly be a good idea to have only one such data collection to
maintain.

>> - zope.publisher.contenttype contains a parser for content-type
>>   specifications.
>> 
>> I propose merging those two packages and one module into one package,
>> zope.contenttype.
[...]
> 
> - How do 'zope.file' and 'zope.filerepresentation' interact with these
>    modules?

zope.file uses zope.mimetype to have a structured way of talking about
content-type-related properties of file objects, and
zope.publisher.contenttype for parsing content-type strings.

zope.filerepresentation only defines some interfaces and uses none of the
modules in question.

> - How do these modules interact with the standard library's 'mimetypes'
>    module?

Both zope.contenttype and zope.mimetype use the mimetypes module to guess
content-types from file names. In fact, both even do some guesswork based
on the first bytes of file content. Probably merging the two involves
essentially dropping one of the implementations.

I also wonder whether it might make sense to utilise the /etc/mime.types
database (or the system's equivalent) for guessing based on the file-name
extension, and libmagic (if available) for magic-number tests based on
file contents. But of course, these ideas don't have much to do with the
restructuring discussed in this thread.

-- 
Thomas



_______________________________________________
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )

Reply via email to