This release is a pre-release and may not be stable for production use.
collective.mtrsetup
collective.mtrsetup provides a GenericSetup extension for importing and exporting mimetypes to / from the mimetypes registry.
How to use
Add collective.mtrsetup as dependency to your setup.py
Add a zcml-include to your configure.zcml or dependency.zcml
Add a dependency to profile-collective.mtrsetup:default to your metadata.xml in your generic setup profile
Create a mimetypes.xml as showed below in your generic setup profile
OpenOffice / Office 2007
There is a additional generic setup profile provided in this package (profile-collective.mtrsetup:default) which adds icons for OpenOffice (with backwards compatiblity to StarOffice) and adds the already used ms-office-icons to the new office 2007 mimetypes. The official Office 2007 icons are not added because of the license.
Examples
Here are some examples of how to use it.
Setup some testing stuff:
>>> from collective.mtrsetup.tests.base import purge_registry, import_mimetypes_registry, \ ... export_mimetypes_registry >>> registry = self.portal.mimetypes_registry >>> purge_registry(registry) >>> len(registry.mimetypes()) 0
We can add new mimetypes with a simple mimetype tag in a mimetypes.xml in our generic setup profile:
>>> filedata = """ ... <?xml version="1.0"?> ... <object name="mimetypes_registry" meta_type="MimeTypes Registry"> ... <mimetype name="Any type" mimetypes="image/any" ... extensions="any" globs="*.any" binary="True" ... icon_path="any.png" /> ... </object> ... """.strip() >>> import_mimetypes_registry(registry, filedata) [(20, 'mimetypes', 'Mimetype imported: <DOM Element: object at ...>')]
Now we should be able to export the current configuration:
>>> print export_mimetypes_registry(registry)
<?xml version="1.0"?>
<object name="mimetypes_registry" meta_type="MimeTypes Registry">
<mimetype name="Any type" binary="True" extensions="any" globs="*.any"
icon_path="any.png" mimetypes="image/any"/>
</object>
We can also just modify a existing one:
>>> filedata = """ ... <object name="mimetypes_registry" meta_type="MimeTypes Registry"> ... <mimetype name="Any type" mimetypes="image/any image/another" /> ... </object> ... """.strip() >>> import_mimetypes_registry(registry, filedata) [(20, 'mimetypes', 'Mimetype imported: <DOM Element: object at ...>')]
The above notiation just updates the mimetype record, where image/any is the first mimetype:
>>> print export_mimetypes_registry(registry)
<?xml version="1.0"?>
<object name="mimetypes_registry" meta_type="MimeTypes Registry">
<mimetype name="Any type" binary="True" extensions="any" globs="*.any"
icon_path="any.png" mimetypes="image/any image/another"/>
</object>
Finally we can delete a mimetype by just adding the delete flag: >>> filedata = “”” … <object name=”mimetypes_registry” meta_type=”MimeTypes Registry”> … <mimetype name=”Any type” mimetypes=”image/any” delete=”True” /> … </object> … “””.strip() >>> import_mimetypes_registry(registry, filedata) [(20, ‘mimetypes’, ‘Mimetype imported: <DOM Element: object at …>’)] >>> print export_mimetypes_registry(registry) <?xml version=”1.0”?> <object name=”mimetypes_registry” meta_type=”MimeTypes Registry”/>
You have to add at least one mimetype, otherwise the import will fail: >>> filedata = “”” … <object name=”mimetypes_registry” meta_type=”MimeTypes Registry”> … <mimetype mimetypes=”” /> … </object> … “””.strip() >>> import_mimetypes_registry(registry, filedata) [(30, ‘mimetypes’, u’Require attributes: “mimetypes” for <mimetype mimetypes=””/>’), (20, ‘mimetypes’, ‘Mimetype imported: <DOM Element: object at …>’)]
Changelog
1.0a1
Added updates for OpenOffice mimetypes (added new icons) and for Office 2007 mimetypes (using the old office-like icons). [12.04.2010, jbaumann]
Assuerd that the GS import/export adapter works on both, plone3 and plone4. Plone3’s getToolByName returns the Tool, with plone4 it returns the Utility. The Tool and the Utility do not have the same interfaces and plone3 crashes when using the old-style utility interfaces for adapter registration - so we need to use a zcml:condition. [12.04.2010, jbaumann]
Implemented exporting, added tests [09.04.2010, jbaumann]
Improved testing system [09.04.2010, jbaumann]
Initial implementation [08.04.2010, jbaumann]
Metadata
Release files for collective.mtrsetup 1.0a1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| collective.mtrsetup-1.0a1.tar.gz | 6.4 kB | Without provenance | Details for collective.mtrsetup-1.0a1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| collective.mtrsetup-1.0a1-py2.4.egg | Legacy Egg format | - | - | Details for collective.mtrsetup-1.0a1-py2.4.egg |
Total release size: 20.5 kB
Release files / collective.mtrsetup-1.0a1.tar.gz
| Download URL | collective.mtrsetup-1.0a1.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7b998d5870f6b00c261ce310544d91d8a39686d34914ef70caea419adafcef40
|
|
BLAKE2b-256 checksum How to use checksums |
5c04dd49b8541cc194aeaa87f05a4442c4dec5d83c98b7d1cb7e96cb04fffccd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / collective.mtrsetup-1.0a1-py2.4.egg
| Download URL | collective.mtrsetup-1.0a1-py2.4.egg |
|---|---|
| Size | 14.1 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
c6416d4593c43dbcf2065009e04d597908a75b83cf486b09f48972e2929e8b58
|
|
BLAKE2b-256 checksum How to use checksums |
64ea1da0a8c2f07ef5217dabd774ea7f836a1537177597846e2258dd4c6c1de9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for collective.mtrsetup 1.0a1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.