Changes between Initial Version and Version 1 of quintagroup.transmogrifier/howto


Ignore:
Timestamp:
Dec 28, 2010 2:48:54 PM (13 years ago)
Author:
olha
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • quintagroup.transmogrifier/howto

    v1 v1  
     1= quintagroup.transmogrifier How to ... = 
     2 
     3Some hints on how to do stuff with transmogrifier one way or another.  
     4 
     5== ... omit a field from an export == 
     6 
     7 * section blueprint: quintagroup.transmogrifier.marshaller 
     8 
     9You can use exclude to specify a field you want to omit on export. 
     10 
     11{{{ 
     12[marshaller] 
     13 
     14blueprint = quintagroup.transmogrifier.marshaller 
     15 
     16exclude = abstract 
     17}}} 
     18 
     19(this is done at the point that marshall is used to create an xml rendition of the content item) 
     20 
     21== ... omit a particular content type == 
     22 
     23 * section blueprint: quintagroup.transmogrifier.sitewalker 
     24 
     25You can set a condition (it has to be a Tales expression): 
     26 
     27{{{ 
     28[sitewalker] 
     29 
     30blueprint = quintagroup.transmogrifier.sitewalker 
     31 
     32condition = python:context.getPortalTypeName() not in ('File', 'Image') 
     33}}} 
     34 
     35(this is done at the point that transmogrifier walks through the site) 
     36 
     37== ... export only a section of the site == 
     38 
     39 * section blueprint: quintagroup.transmogrifier.catalogsource 
     40 
     41You can set a catalog query (rather than use a sitewalker) 
     42 
     43{{{ 
     44[catalogsource] 
     45 
     46blueprint = quintagroup.transmogrifier.catalogsource 
     47 
     48modified = query = 2008-11-02T12:00:00Z; range = min 
     49}}} 
     50 
     51Note 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. 
     52 
     53== ... switch from workflow to another == 
     54 
     55You 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. 
     56 
     57    * product: quintagroup.transmogrifier 
     58    * section blueprint: quintagroup.transmogrifier.datacorrector 
     59 
     60With 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. 
     61... apply a workflow transition 
     62 
     63    * product: plone.app.transmogrifier 
     64    * section blueprint: plone.app.transmogrifier.workflowupdater 
     65 
     66... migrate content from one content type to another 
     67 
     68If 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. 
     69 
     70Alternatively, 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). 
     71 
     72I still haven't cracked this one completely - so the following is work in progress: 
     73 
     74Quintagroup 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. 
     75 
     76[substitution] 
     77 
     78blueprint = quintagroup.transmogrifier.substitution 
     79 
     80key = _type 
     81 
     82Blog = Weblog 
     83 
     84PloneFormMailer = FormFolder 
     85 
     86.... import a CSV file 
     87 
     88    * product: collective.transmogrifier 
     89    * blueprint: collective.transmogrifier.sections.csvsource 
     90 
     91If 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: 
     92 
     93    * _type 
     94    * _path 
     95    * 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) 
     96 
     97[csvsource] 
     98blueprint = collective.transmogrifier.sections.csvsource 
     99filename = /Users/abowtell/Documents/buildingcapacity/testdatasets.csv 
     100.... adding _type and _path to your csv file 
     101 
     102You can add these as columns to your spreadsheet or just insert them into the content pipeline item: 
     103 
     104[itemType] 
     105 
     106blueprint = collective.transmogrifier.sections.inserter 
     107 
     108key = string:_type 
     109 
     110value = string:Dataset 
     111 
     112... convert a string of comma separated keywords in your csv file into a python list 
     113 
     114[keywords] 
     115 
     116blueprint = collective.transmogrifier.sections.inserter 
     117 
     118key = string:keywords 
     119 
     120value = python:item['keywords'].split(",") 
     121 
     122 
     123... take a whole load of flat HTML files and turn them into a Plone site 
     124 
     125Well 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.