开发者

Easiest way to specify alternate transmogrifier _path?

开发者 https://www.devze.com 2023-03-24 04:26 出处:网络
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 开发者_C百科like t

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 开发者_C百科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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消