Zope ContentType is a utility module within the Zope ecosystem designed for handling MIME types, particularly the 'Content-Type' HTTP header. It provides functionalities for guessing content types from filenames and (optional) data, determining content types from text, and parsing MIME type strings. Currently at version 6.0, the library follows semantic versioning with new minor releases approximately every 2-6 months and major releases every 2-3 years, in line with the broader Zope project.
pip install zope.contenttypeVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to guess content types using filenames and binary data, and how to parse a full content type string into its components. This covers the most common use cases for `zope.contenttype`.
Ensure your build tools and environment support PEP 420 native namespace packages. For `zc.buildout`, upgrade to version 5 or newer. Review any explicit `namespace_packages` configurations in `setup.py` files if upgrading from very old versions.
Upgrade your Python environment to version 3.9 or higher to use `zope.contenttype` version 6.0. Python 3.9 is the minimum required version for `zope.contenttype` 6.0.
Ensure that the `file_contents` argument passed to `guess_content_type` is always a `bytes` object (e.g., `b'your data'`) when running on Python 3.
If your application relies on a stricter content type guessing, you may need to implement custom logic or override `guess_content_type` to call `mimetypes.guess_type(strict=True)` directly or filter its results.
Convert the string to bytes before passing it, e.g., `guess_content_type(filename, my_string.encode('utf-8'))`.Install the package using pip: `pip install zope.contenttype`. If using a virtual environment, ensure it is activated.
Update your `zc.buildout` to version 5 or newer, or ensure your project setup correctly handles PEP 420 namespace packages. This generally means removing `namespace_packages` from `setup.py` for modern Python versions.
No dependency data recorded yet.