This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!
Project Description

This Plone add-on can be used to update broken mimetypes of Blob fields.

When a file or an image is uploaded to a Blob field, its mimetype is computed based on information from the mimetypes_registry.

If that registry misses some information, the computed mimetype can be wrong or too general.

For instance, prior to version 2.0.7 of Products.MimetypeRegistry, the default mimetypes_registry of a Plone portal did not know of OpenXML mimetypes. Those files would get application/zip mimetype instead of their proper mimetypes.

As computation of mimetype happens only at load time, upgrading Products.MimetypeRegistry is not enough to fix broken mimetypes.

The function collective.updatemimetype.migrate walks over content, looks for blob fields that would get different mimetype if they would be uploaded again, and updates those field mimetypes. It can be called from a GenericSetup upgrade step with:

from collective.updatemimetype import migrate

migrate(portal)

Caution!

The update can demand a lot of memory and take a long time if your portal holds a lot of content.

If you want to limit migration to specific content items, you can pass a query argument to the migrate function. For instance, while the code above updates both File and Image content items of a default Plone site, the code below would only update File content items:

from collective.updatemimetype import migrate

catalog_query = {'portal_type': 'File'}

migrate(portal, catalog_query)

There is also a view registered on the portal. Call it with:

http://my_domain/my_portal/updatemimetype

The view can also be called with a query parameter. To limit update to File items, call the view with:

http://my_domain/my_portal/updatemimetype?query.portal_type:record:string=File

Contributors

Changelog

0.1.2 (2015-07-06)

  • Fix limiting update to the results of a catalog query. And document how to do it. [gotcha]

0.1.1 (2015-06-30)

  • Fix classifier [gotcha]

0.1 (2015-06-29)

  • Initial release. [gotcha]
Release History

Release History

0.1.2

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
collective.updatemimetype-0.1.2.zip (27.9 kB) Copy SHA256 Checksum SHA256 Source Jul 6, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting