为使用transmogrifier进行迁移提供有用的蓝图
项目描述
ftw.blueprints
ftw.blueprints 提供了一些有用的蓝图,并包含 archetypes 和 dexterity 的示例 cfg。
有关创建蓝图和使用它们的更多信息,请参阅
安装
将 ftw.blueprints 添加到您的 buildout 配置中
[instance]
eggs +=
ftw.blueprints
打开视图 @@jsonmigrator 并选择您的配置文件
注意:一些 Archetypes 和 Dexterity 的示例配置还引用了来自 ftw.inflator 的部分。如果您的配置基于其中之一,您还需要安装 ftw.inflator。
兼容性
与 Plone 4.2、4.3 或 5.0 兼容。
Plone 4.2
Plone 4.3
Plone 5.0
本包提供的蓝图
- ftw.blueprints.fieldmapper
强大的蓝图,可用于将给定项目中的字段映射和更改为静态值、lambda 表达式、条件和大字典映射。
- ftw.blueprints.pathmapper
将旧路径映射到新路径。如果需要,递归应用映射。
- ftw.blueprints.childinserter
为给定项目插入子项目
- ftw.blueprints.parentinserter
为给定项目插入父项目
- ftw.blueprints.additionalobjectinserter
在给定路径插入对象
- ftw.blueprints.dataupdater
更新 blob 数据。
- ftw.blueprints.regexreplacer
使用正则表达式替换值
- ftw.blueprints.logger
printer 蓝图的替代品。可配置的日志蓝图,用于记录表达式中给出的信息。
- ftw.blueprints.workflowmanager
管理工作流状态、转换和历史记录
- ftw.blueprints.formmailer-fields-inserter
将非常旧的PloneFormMailer字段转换为新的PloneFormGen架构字段蓝图
- ftw.blueprints.contextualportletadder
在指定的上下文中添加一个组件
- ftw.blueprints.unicodeawaremimeencapsulator
支持Unicode的plone.app.transmogrifier.mimeencapsulator。
- ftw.blueprints.multilingual.linguaploneitemlinker
使用plone.app.multilingual从使用LinguaPlone的源创建新的翻译
- ftw.blueprints.positionupdater
在父蓝图中的对象位置,支持Plone站点。
- 建设中/已弃用
ftw.blueprints.annotatedefaultviewpathobjects
ftw.blueprints.updatedefaultviewobjectpath
ftw.blueprints.checkisdefaultviewobject
ftw.blueprints.fieldmapper
此蓝图用于在项目上映射或更改值。
必需选项
字段映射 - 映射或更改字段的选项
使用字段映射
{‘source-key’: {option: value}}
首先,您需要定义要修改的源键。
然后您需要定义一些选项
目的地:键的新名称。
{‘plz’: {‘destination’:’zip’}}
仅将plz的值移动到zip
静态值:如果您想使用静态值,可以使用此选项
{‘plz’: {‘static_value’:’3000’}}
用3000替换plz中的值
映射值:在某些情况下,您想使用映射来更改值
{‘plz’: {‘map_value’:{‘PLZ 3000’: ‘3000’}}}
如果plz的值是PLZ 3000,它将被替换为3000
转换:使用给定的函数转换值。参数是项目本身。
- {‘plz’: {‘transform’:lambda x: x[‘plz’] = x[‘plz’] and
x[‘plz’] or ‘3000’}}
此示例将如果plz的值为None,则将plz替换为3000
需要src_key:在某些情况下,您只想在源键存在时执行转换。
{‘plz’: ‘static_value’:’3000’, need_src_key: True}
如果源键在项目上存在,它将只设置静态值。
选项“need_src_key”默认为False。因此,您可以将映射器用作更强大的插入蓝图。例如,您可以为项目添加一个尚不存在的新属性。如果源键在项目上不存在,它将被映射器忽略。
{'update_show_title': {
'destination': 'showTitle',
'transform': lambda x: x['title'] and True or False,
}
}
此示例将在项目标题不为空的情况下,将尚不存在的新属性“showTitle”设置为True。
还可以在转换属性之后将其与map_value选项一起映射。
{'title': {
'destination': 'description',
'transform': lambda x: x['title'].lower(),
'map_value': {'james': 'bond', 'bud': 'spencer'}
}
}
首先将标题转换为小写。如果标题包含map_value选项中给出的键之一,它将被替换。最后,将转换并映射的值放入描述中。
您可以将所有这些选项组合起来,在项目上进行强大的映射。
{'zip': {'static_value':'3000'},
'client': {
'destination': 'text',
'transform': lambda x: x['language'] == \
'en' and 'Customer: %s' % (x['cleint']) or \
'Kunde: %s' % (x['client']),
'need_src_key': True
}
}
首先,我们将静态值放入zip属性中。然后我们对client属性执行一些操作。如果client-key在项目映射中可用,它根据对象的语言填充一个给定的字符串,并将其放入文本属性中。
最小配置
[fieldmapper]
blueprint = ftw.blueprints.fieldmapper
field-mapping = python:{}
可选选项
没有可选选项。
ftw.blueprints.pathmapper
此蓝图更新每个项目的路径。
必需选项
映射
映射的可迭代序列。
每个映射项是一个元组(正则表达式,替换)。
映射按定义的顺序逐一应用。
表达式,可迭代对象
最小配置
[pathmapper]
blueprint = ftw.blueprints.pathmapper
mapping = python: (
('^/de/foo/bar', '/foo/bar'),
('^/en/foo/bar', '/foo/qux'),)
可选选项
路径键 - 被映射的路径的键名。默认为_path。
strip_prefixes - 从每个路径中删除的列表前缀,如果路径以该前缀开头。
完整配置
[pathmapper]
blueprint = ftw.blueprints.pathmapper
mapping = python: (
('^/de/foo/bar', '/foo/bar'),
('^/en/foo/bar', '/foo/qux'),)
path-key = '_gak'
strip-prefixes = python: (
'/plone/www/irgendwo',)
ftw.blueprints.typefieldmapper
此蓝图将类型及其字段映射到新类型和新字段。
必需选项
映射
类型及其字段的嵌套映射。
第一级映射类型。
第二级映射第一级类型的字段。
表达式,字典
最小配置
[typefieldmapper]
blueprint = ftw.blueprints.typefieldmapper
mapping = python: {
'OldType': ('NewType', {'oldfield': 'newfield'}),
}
可选选项
类型键 - 被映射的类型键名。默认为_type。
ftw.blueprints.childinserter
此蓝图将作为子项插入新项目到管道中。
新项目不是父项的副本。如果您想使用父项的元数据,您需要使用metadata-key选项映射它们
必需选项
内容类型 - 定义子对象的内容类型 - 字符串
additional-id - 定义子对象的新的ID - 表达式,字符串
-最小配置
[childinserter]
blueprint = ftw.blueprints.childinserter
content-type = ContentPage
additional-id = python: 'downloads'
可选选项
metadata-key - 将子对象作为字典的元数据映射。您可以提供来自父项的元数据以供子对象使用,或者可以使用lambda表达式设置新的值。- 表达式,字典
使用父级元数据
{‘description’: ‘title’}
将获取父项上的title值并将其放入子项上的description字段
使用新值
{‘title’: lambda x: ‘Images’}
将‘Images’放入子项上的title字段
_interfaces - 将接口作为列表添加到子项 - 表达式,列表
_annotations - 将注释作为字典添加到子项 - 表达式,字典
完整配置
[childinserter]
blueprint = ftw.blueprints.childinserter
content-type = ContentPage
additional-id = python: 'downloads'
metadata-key = python: {
'title': lambda x: 'Images',
'description': 'title',
}
_interfaces = python: [
"simplelayout.portlet.dropzone.interfaces.ISlotBlock",
"remove:simplelayout.base.interfaces.ISlotA"
]
_annotations = {'viewname': 'portlet'}
可视化示例
A = 管道中的项
A’ = 蓝图后的管道中的项
B = 项后的子项
+-------------------+
| _path: /foo |
| _id: album | (A)
| _type: Folder |
+---------+---------+
|
| 1.0
|
+--------------+------------------+
| BLUEPRINT |
| content-type = Image |
| additional-id = python: 'bar' |
| |
+--+------------------------+-----+
| |
| | 1.2
| +-----+-------------+
| 1.1 | _path: /foo/bar |
| | _id: bar | (B)
| | _type: Image |
| +-----+-------------+
+---------+---------+ |
| _path: /foo | |
| _id: album | (A') |
| _type: Folder | |
+---------+---------+ |
| |
| 1.1.1 | 1.2.1
| |
+--+------------------------+-----+
ftw.blueprints.parentinserter
此蓝图将新项作为父项插入管道。
新项不是子项的副本。如果您想使用子项的元数据,您需要使用metadata-key选项进行映射
请参阅ftw.blueprints.childinserter部分文档了解如何使用。
可视化示例
A = 管道中的项
A’ = 蓝图后的管道中的项
B = 项后的管道中的父项
+-------------------+
| _path: /foo |
| _id: album | (A)
| _type: Image |
+---------+---------+
|
| 1.0
|
+--------------+------------------+
| BLUEPRINT |
| content-type = Folder |
| additional-id = python: 'bar' |
| |
+--+------------------------+-----+
| |
| | 1.2
| +-----+-------------+
| 1.1 | _path: /bar/foo |
| | _id: album | (A')
| | _type: Image |
| +-----+-------------+
+---------+---------+ |
| _path: /bar | |
| _id: bar | (B) |
| _type: Folder | |
+---------+---------+ |
| |
| 1.1.1 | 1.2.1
| |
+--+------------------------+-----+
ftw.blueprints.additionalobjectinserter
此蓝图将在给定路径处将新项插入管道。
新项不是项的副本。如果您想使用项的元数据,您需要使用metadata-key选项进行映射
必需选项
new-path - 包括要创建的对象ID的路径 - 表达式,字符串
content-type - 定义新对象的内容类型 - 字符串
additional-id - 定义新对象的新的ID - 表达式,字符串
最小配置
[additionalobjectinserter]
blueprint = ftw.blueprints.additionalobjectinserter
content-type = Contact
additional-id = python: 'downloads'
new-path = python:'/contacts/contact-%s' % item['_id']
请参阅ftw.blueprints.childinserter部分文档了解有关可选选项的更多信息。
可视化示例
A = 管道中的项
A’ = 蓝图后的管道中的项
B = 项后的管道中的父项
+-------------------+
| _path: /foo |
| _id: album | (A)
| _type: Image |
+---------+---------+
|
| 1.0
|
+--------------+-----------------------+
| BLUEPRINT |
| content-type = Contact |
| additional-id = python: 'bar' |
| new-path = python:'/contacts/james |
| |
+--+------------------------+----------+
| |
| | 1.2
| +-----+-------------+
| 1.1 | _path: /foo |
| | _id: album | (A')
| | _type: Image |
| +-----+-------------+
+---------+----------------+ |
| _path: /contacts/james | |
| _id: bar | (B) |
| _type: Contact | |
+---------+----------------+ |
| |
| 1.1.1 | 1.2.1
| |
+--+------------------------+----------+
ftw.blueprints.workflowmanager
管理迁移后工作流程的蓝图
使用此蓝图可以迁移工作流程历史记录和审核状态。
它提供工作流程映射、状态映射和转换映射。
必需选项
old-workflow-id - 要迁移的旧工作流程的名称 - 字符串
最小配置
[workflowmanager]
blueprint = ftw.blueprints.workflowmanager
old-workflow-id = simple_publication_workflow
可选选项
update-history - 默认:True - 如果只想更新review_state,则将其设置为False
new-workflow-id - 如果新工作流程的名称与旧工作流程不同。 - 字符串
state-map - 将旧状态映射到新状态的映射 - 表达式,字典
transition-map - 将旧转换映射到新转换的映射 - 表达式,字典
完整配置
[workflowmanager]
blueprint = ftw.blueprints.workflowmanager
old-workflow-id = IntranetPublicationWorkflow
new-workflow-id = intranet_secure_workflow
state-map = python: {
'draft': 'intranet_secure_workflow--STATUS--draft',
'published': 'intranet_secure_workflow--STATUS--published',
'revision': 'intranet_secure_workflow--STATUS--revision'}
transition-map = python: {
'publish': 'intranet_secure_workflow--TRANSITION--publish',
'retract': 'intranet_secure_workflow--TRANSITION--retract'}
ftw.blueprints.contextualportletadder
将端口组件插入指定上下文的蓝图。
必需选项
- manager-name
要添加端口组件的端口管理器名称
字符串
- assignment-path
要添加的端口分配的点名称路径
字符串
- portlet-id
要添加的端口组件的ID
字符串
最小配置
[contextualportletadder]
blueprint = ftw.blueprints.contextualportletadder
manager-name = plone.rightcolumn
assignment-path = ftw.contentpage.portlets.news_archive_portlet.Assignment
portlet-id = news_archive_portlet
可选选项
- portlet-properties
端口分配的默认属性
表达式,字典
ftw.blueprints.formmailer-fields-inserter
将非常旧的PloneFormMailer字段转换为新的PloneFormGen架构字段蓝图
将PloneFormMailer的字段转换为问题的方法是,它们不是像PloneFormGen那样的Archetype字段。为了自动转换,我们使用Formulator包中的formXML函数,并将导出的xml-表单表示形式放入使用collective.jsonify导出的项中。
通过管道创建表单本身之后,我们解析xml并将其转换为具有archetypes字段的transmogrifier项。
请参阅ftw.blueprints.pfm2pfg配置示例,了解如何正确地将PloneFormMailer迁移集成到管道中。
最小配置
[formmailer-fields-inserter]
blueprint = ftw.blueprints.formmailer-fields-inserter
ftw.blueprints.unicodeawaremimeencapsulator
使plone.app.transmogrifier.mimeencapsulator接受Unicode输入数据。配置选项没有变化。请参阅transmogrifier文档。
ftw.blueprints.multilingual.linguaploneitemlinker
使用plone.app.multilingual链接新Plone站点中的翻译。它假定源已使用LinguaPlone翻译。此外,它假定在运行此部分时新站点中的Plone内容已构建。
请注意,在映射路径时,还应将相同的映射应用于对规范翻译(_translationOf)的引用。
最小配置
[multilingual]
blueprint = ftw.blueprints.multilingual.linguaploneitemlinker
可选选项
path-key - 新项路径的键名。默认为_path。
规范键 - 指示此项目是否为规范翻译的布尔值的键名。默认为_canonicalTranslation。
translationOf - 指向规范翻译的键名。默认为_translationOf。
ftw.blueprints.positionupdater
positionupdater 蓝图支持文件夹和Plone网站。它在每个对象的注释中存储期望的位置,这样我们就可以单独迁移子对象,但保持位置(例如,一次FTI)。
[position]
blueprint = ftw.blueprints.positionupdater
可选
path-key - 新项目路径的键名。默认为_path。
position-key - 项目位置的键名。默认为_gopip。
链接
版权
本软件包版权所有 4teamwork。
ftw.blueprints 根据 GNU 通用公共许可证,版本 2 许可。
变更日志
1.1.1 (2017-01-09)
多语言:编码 canonicalpath。[libargutxi]
1.1.0 (2016-08-29)
修复Plone 5测试
确保设置Unicode标题。
在Plone 5测试期间安装 p.a.contenttypes:default 配置文件
在测试中使用条件导入以实现Plone 4/5兼容性。
确保我们在Plone 4和5上具有一致的ID。
[lgraf]
将ILanguage导入设置为条件,以便它在Plone 4和Plone 5上都能正常工作。[lgraf]
不要对 ftw.inflator 强制依赖。这使得即使在 ftw.inflator 尚未升级的情况下,也能在Plone5中使用 ftw.blueprint 部分。[Guido A.J. Stevens]
更新导入以与Plone 4和5兼容[Guido A.J. Stevens]
更新导入以与Plone 5兼容[erral]
1.0.0 (2015-09-30)
初始发布
项目详情
ftw.blueprints-1.1.1.tar.gz 的散列
算法 | 散列摘要 | |
---|---|---|
SHA256 | 9e89b39d766edfe0eeb301237e2ca0f884ca14960df472b1c52f1ba922903606 |
|
MD5 | 97ed14260187cd0089d2a48b7a0726e2 |
|
BLAKE2b-256 | 891e5cb8d10698959475f708dab816b3d587720b93c09b3184bb4359426fd399 |