Package: collective.contentexport
collective.contentexportFeaturesExports dexterity content in various formats:xlsxxlscsvtsvjsonyamlhtml (a table)zip-file containing all images from image-fieldszip-file containing all files from file-fieldszip-file containing related files and images from relationfieldsIt can be used to export all instances of a dexterity type and all its data. It cannot be used to export a folder-structure of content.UsageProvides a form/@@collective_contentexport_viewto configure the export. The form is also availabe in the main controlpanel asContent export.The form allows you to:Select the export typeSelect the content type to exportChoose fields from the selected type to be ignoredSelect the format of richtext-fields (html/plaintext)Select the format for files and images (url, base64, location within zip-file)collective.contentexport usestablibfor several export-formats.Use in codeYou can use thecollective_contentexport_viewin code to have more control over the results.The viewcollective_contentexport_viewaccepts the following parameters:export_typeThe export-format you want to use. Accepts the following options:xlsx (Excel Spreadsheet (xlsx))xls (Excel Legacy Spreadsheet (xls))yaml (YAML)html (HTML Table)csv (Comma Separated Values File)tsv (Tab Separated Values File)json (JSON Dump)images (Export images as zip)files (Export files as zip)related (Export related files and images as zip)portal_typeThe content-type you want to exportblob_formatThe format in which blobs (filed/images) should be exported. Accepts the following options:url (URL)base64 (Base64-encoded string)zip_path (Location within the a zip)richtext_formatThe format in which richtext (html) should be exported. Options:htmltext/plainblacklistFields that should be ommited from the export (cannot be combined with whitelist).whitelistOnly these fields should be included in the export (cannot be combined with blacklist).additionalAdditional data to export. A dict with a name (for the heading) as key and a callable method as value to get additional data for the export from the objects.queryCatalog-query to filter the exported content.The following example creates a zip-file with images or files from the fieldprimary_picturefor the typesome_type:view=api.content.get_view('collective_contentexport_view',portal,request)view(export_type='related',portal_type='some_type',whitelist='primary_picture')You can filter the items that should be exported by passing a catalog-query:path='/'.join(self.context.getPhysicalPath())view=api.content.get_view('collective_contentexport_view',portal,request)view(export_type='json',portal_type='Document',query={'review_state':'published','path':path})You can also extend the export.
In the following example the valuesome_fieldnameis being extracted from the object using the method_somehandler.def_somehandler(obj):returnsome_crazy_transform(obj.custom_field)additional={'some_fieldname':_somehandler}view=api.content.get_view('collective_contentexport_view',portal,request)result=view(export_type='json',portal_type='Document',additional=additional)You can also override the default methods to modify the default behavior.
In the following example theimagefrom Images is being extracted using the method_get_imagenamethat only dumps the filename of the image:def_get_imagename(obj):ifobj.image:returnobj.image.filenameadditional={'image':_get_imagename}view=api.content.get_view('collective_contentexport_view',portal,request)result=view(export_type='json',portal_type='Image',additional=additional)Compatabilitycollective.contentexport is tested to work in Plone 4.3, Plone 5 and PLone 5.1.Known Issuesxslx-Export is broken unless you pinnopenpyxl = 2.4.9. Seehttps://github.com/collective/collective.contentexport/issues/4for details.InstallationInstall collective.contentexport by adding it to your buildout:[buildout]

...

eggs =
    collective.contentexportand then runningbin/buildout.You don’t need to install the add-on to use the export.ContributeIssue Tracker:https://github.com/collective/collective.contentexport/issuesSource Code:https://github.com/collective/collective.contentexportSupportIf you are having issues, please let us know athttps://github.com/collective/collective.contentexport/issues.LicenseThe project is licensed under the GPLv2.ContributorsPhilip Bauer,bauer@starzel.deChangelog1.1 (2018-03-27)Add modification date to default fields
[pbauer]Add export-view to controlpanel
[pbauer]Run tests with Plone 5.1
[pbauer]1.0 (2016-07-09)Fix tsv-Export
[pbauer]Test compatibility with Plone 5.0.5
[pbauer]1.0b5 (2015-12-03)Fix UnicodeEncodeError in get_blob_url when filenames have special characters.
[pbauer]Add path and review_state to exported data that is not part of the schema.
[pbauer]1.0b4 (2015-11-28)Allow to pass catalog-query to filter the exported content.
[pbauer]1.0b3 (2015-11-28)Move package tohttps://github.com/collective/collective.contentexport.
[pbauer]No longer bind views to browserlayer to simplify package-use. Rename views
to prevent unintended name-clashes since we no longer use the browser-layer.
[pbauer]1.0b2 (2015-11-06)Add whitelist (only export fields in the whitelist)
[pbauer]Document extending and overriding the export.
[pbauer]1.0b1 (2015-11-05)Sort fieldnames in blacklist by alphabet.
[pbauer]Add ability to provide additional export-methods for arbitrary data by
extending ADDITIONAL_MAPPING.
[pbauer]Add tests
[pbauer]1.0a2 (2015-11-04)Localize datetime
[pbauer]Prevent uneven dimension of data-dict
[pbauer]Fix blacklist
[pbauer]1.0a1 (2015-11-04)Get content from all languages.
[pbauer]Add export for multiple images and files related with RelationList.
[pbauer]Allow choosing blacklisted fields from the fields of the selected type.
[pbauer]Usehttp://docs.python-tablib.orgfor most exports.
[pbauer]Add German translations.
[pbauer]Moved initial code from client-project to github.
[pbauer]