Over the time i've been looking for a way to import and export content from Plone to Plone or AnyData to Plone with the minimal specific programming possible.
Every time we had (in the business I work) to do an export/import of content we used to create an external method which handles the task, so over time I tried different ways to automate the process and the solutions I finished implemented are python classes which, with minimum configuration, handle all the process by themselves.
Right now I got 2 classes one for the exporter and other for the importer:
The exporter takes as parameters the portal object, the schema of the archetype to export (never needed to export dexterity for the moment) and the metatype of the content type.
It generates a XML with all the info needed to the other class about the fields and a log file of the process.
def my_external_method(self): portal_url = getToolByName(self, 'portal_url') portal = portal_url.getPortalObject() export = Exporter( portal, MyContentType.schema, # My Archetype schema MyContentType.MyContentType.meta_type) # meta_type name for query catalog
The importer takes as parameters the portal object, the path to the xml file, and the path of the folder where you want to store the objects. Thats all, if you want/need you can define a mapping of the attributes and filters for the values (everything explained at the repo).
def my_external_method(self): portal_url = getToolByName(self, 'portal_url') portal = portal_url.getPortalObject() Importer( portal = portal, xml_path = '/tmp/import/Event.xml', folder_path = '/fs-mysite/mysite/activity-schedule')
I've been thinking about turning it into a product with an ajax UI and add to the exporter the ability to export all the data in a nested way, and by this way reproduce all the tree structure from one Plone to another.
Had an other class to import to Archetypes, but is one of the first things I programmed for Plone and we don't use Archetypes anymore: