Easiest way to specify alternate transmogrifier _path?

3.4k Views Asked by At

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?

1

There are 1 best solutions below

6
On BEST ANSWER

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.