wiki:quintagroup.transmogrifier/howto

Version 1 (modified by olha, 13 years ago) (diff)

--

quintagroup.transmogrifier How to …

Some hints on how to do stuff with transmogrifier one way or another.

... omit a field from an export

  • section blueprint: quintagroup.transmogrifier.marshaller

You can use exclude to specify a field you want to omit on export.

[marshaller]

blueprint = quintagroup.transmogrifier.marshaller

exclude = abstract

(this is done at the point that marshall is used to create an xml rendition of the content item)

... omit a particular content type

  • section blueprint: quintagroup.transmogrifier.sitewalker

You can set a condition (it has to be a Tales expression):

[sitewalker]

blueprint = quintagroup.transmogrifier.sitewalker

condition = python:context.getPortalTypeName() not in ('File', 'Image')

(this is done at the point that transmogrifier walks through the site)

... export only a section of the site

  • section blueprint: quintagroup.transmogrifier.catalogsource

You can set a catalog query (rather than use a sitewalker)

[catalogsource]

blueprint = quintagroup.transmogrifier.catalogsource

modified = query = 2008-11-02T12:00:00Z; range = min

Note this is a slightly complex example, because the query parameter itself is a dict. You'll need to be fairly comfortable with writing catalog queries.

... switch from workflow to another

You probably only need to do this if the workflow you want to abandon is not installed on the new site (and you don't want to install it). Otherwise use the types tool in site setup which does a much better job.

  • product: quintagroup.transmogrifier
  • section blueprint: quintagroup.transmogrifier.datacorrector

With this method, you actually rewrite the xml that is generated by Marshall and packaged up as part of the content pipeline item. You'll need to write an adapter for this (up to you whether you do this as an export or import step) - which is complicated enough to need a page of instructions of its own. ... apply a workflow transition

  • product: plone.app.transmogrifier
  • section blueprint: plone.app.transmogrifier.workflowupdater

... migrate content from one content type to another

If this is a one-off migration, then you might want to consider your options - with just a few items to migrate you may want to think about cutting and pasting, or digging out your regular expressions to manually search and replace the xml files in between the export and import.

Alternatively, on import, you can use either the transmogrifier datacorrector blueprint to rewrite the xml or the transmogrifier xslt blueprint to transform it (the latter won't work on a mac though).

I still haven't cracked this one completely - so the following is work in progress:

Quintagroup themselves have written a couple of products undertaking specific migrations, so these give you a good idea of what you need to do. It seems to me the trick is understanding what information is conveyed by the key value pairs comprising the content pipeline item and the xml that's packaged up with the pipeline item. It's certainly possible to replace the value of a key in the pipeline item - but that probably wouldn't be enough to migrate content where fields have different names etc.

[substitution]

blueprint = quintagroup.transmogrifier.substitution

key = _type

Blog = Weblog

PloneFormMailer? = FormFolder?

.... import a CSV file

  • product: collective.transmogrifier
  • blueprint: collective.transmogrifier.sections.csvsource

If you can edit your csv file beforehand, then just make sure that your column names map to the field names of your content type. To get this to work, you'll need three things:

  • _type
  • _path
  • the path actually to exist in your site before you import (e.g. if you're planning to import all your items to a folder called datasets, then you need to have created that)

[csvsource] blueprint = collective.transmogrifier.sections.csvsource filename = /Users/abowtell/Documents/buildingcapacity/testdatasets.csv .... adding _type and _path to your csv file

You can add these as columns to your spreadsheet or just insert them into the content pipeline item:

[itemType]

blueprint = collective.transmogrifier.sections.inserter

key = string:_type

value = string:Dataset

... convert a string of comma separated keywords in your csv file into a python list

[keywords]

blueprint = collective.transmogrifier.sections.inserter

key = string:keywords

value = python:item['keywords'].split(",")

... take a whole load of flat HTML files and turn them into a Plone site

Well I haven't tried this yet, but there's a project, originally called Funnelweb, which has created a series of blueprints to trawl and convert HTML files to turn into transmogrifier items for insertion into Plone. Search for transmogrify on Pypi.