跳转到主要内容

基于Products.contentmigration的内容迁移向导

项目描述

简介

由 Giacomo Spettoli <giacomo.spettoli@gmail.com> 和 Regione Emilia-Romagna

该产品是基于框架Products.contentmigration的内容迁移的用户界面。

向导将指导网站管理员通过3个步骤进行迁移:

  1. 从列表中选择所需的迁移

  2. 从过滤的站点图中选择应用迁移的内容

  3. 确认迁移。

此产品还提供了一种注册新迁移的简单方法。在“allmigration”文件夹中您可以找到一些示例。这里展示的是folderToLargeFolder迁移。

class FolderToLargePloneFolder(object, ATFolderMigrator):
    """Migrate the old item type to the new item type
    """
    implements(IContentMigrator)

    walker = CustomQueryWalker
    src_meta_type = "ATFolder"
    src_portal_type = "Folder"
    dst_meta_type = "ATBTreeFolder"
    dst_portal_type = "Large Plone Folder"
    description = "Document to Document"
    safeMigration = True

    def __init__(self, *args, **kwargs):
        ATFolderMigrator.__init__(self, *args, **kwargs)
        self.fields_map = BASE_AT_PROPERTIES

FolderToLargePloneFolderMigrator = FolderToLargePloneFolder

为了创建您自己的迁移,您必须创建一个扩展ATFolderMigrator或ATItemMigrator的类

from Products.contentmigration.archetypes import ATFolderMigrator,ATItemMigrator

此新类必须实现IContentMigrator接口

implements(IContentMigrator)

接下来,您需要插入源和目标portal_type和meta_type(您可以在zmi/portal_types中找到这些值)

src_meta_type = "ATFolder"
src_portal_type = "Folder"
dst_meta_type = "ATBTreeFolder"
dst_portal_type = "Large Plone Folder"

您可以设置迁移为“安全”或“不安全”。一个“安全”的迁移是指目标内容类型与原始内容类型具有相等或更多的字段。您还可以在描述中插入一个警告信息

safeMigration = True
description = "Document to Document"

然后,在__init__方法中,您必须在目标字段中映射源字段。基本archetypes字段已经在BASE_AT_PROPERTIES中映射

self.fields_map = BASE_AT_PROPERTIES
最后,插入此行以创建一个命名工具:

<类名>Migrator = <类名>

在zcml文件中注册新工具

<utility
    component=".basemigrations.FolderToLargePloneFolderMigrator"
    provides="..interfaces.IContentMigrator"
    name="collective.contentmigrationui.FolderToLargePloneFolderMigrator"
/>

变更日志

0.1

  • 初始发布

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源代码分发

本发布版本没有提供源代码分发文件。请参阅生成分发存档的教程

构建分发

collective.contentmigrationui-0.1-py2.4.egg (52.1 kB 查看哈希值)

上传时间 源代码

由以下支持