1

I'm doing a content migration with collective.transmogrifier and I'm reading files off the file system with transmogrify.filesystem. Instead of importing the files "as is", I'd like to import them to a sub directory in Plone. What is the easiest way to modify the _path?

For example, if the following exists:

  • /var/www/html/bar/index.html

I'd like to import to:

  • /Plone/foo/bar/index.html

In other words, import the contents of "baz" to a subdirectory "foo". I see two options:

  • Use some blueprint in collective.transmogrifier to mangle _path.
  • Write some blueprint to mangle _path.

Am I missing anything easier?

aclark
  • 4,345
  • 1
  • 19
  • 31

1 Answers1

4

Use the standard inserter blueprint to generate the paths; it accepts python expressions and can replace keys in-place:

[manglepath]
blueprint = collective.transmogrifier.sections.inserter
key = string:_path
value = python:item['_path'].replace('/var/www/html', '/Plone/foo')

This thus takes the output of the value python expression (which uses the item _path and stores it back under the same key.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
  • Hmmm, this works great to mangle the path, but then I get: 2011-07-31 19:05:53 WARNING collective.transmogrifier.constructor Container foo/vel does not exist for item /foo/vel/index.html. Strange, since it seems to not mind creating folders for content that actually exists (i.e. folders in the pre-mangled path get created fine when you don't mangle the path.) – aclark Jul 31 '11 at 23:07
  • the creator blueprint really likes things to be sorted in path order, ie folders first. transmogrify.pathsorter was written to get around this problem. It also creates new items for folders with a given _type. – djay Aug 01 '11 at 02:37
  • I see what happened, I need to make sure I insert the new path at least once alone, AKA "sorted input" (as pathsorter hopefully will do for me). – aclark Aug 01 '11 at 03:41
  • @djay Or just use the [collective.transmogrifier.sections.folders](http://pypi.python.org/pypi/collective.transmogrifier#folders-section) blueprint to create folders on the fly as needed. – Martijn Pieters Aug 01 '11 at 07:33
  • Has anyone noticed any "strange behavior" with the folders blueprint? AFAICT, the constructor blueprint creates folders (with sorted input), but the folders section does not create folders with any input. – aclark Aug 01 '11 at 13:59
  • The folders blueprint doesn't create folders directly; it inserts instructions for the constructor to create folders before items inside those folders in the item stream. – Martijn Pieters Aug 01 '11 at 15:12