Plone:collective.transmogrifier.sections.constructor在导入

时间:2015-08-13 16:00:08

标签: plone data-migration plone-4.x transmogrifier

我几乎成功地将我的ZODB(一小部分文件夹,包括从其他文件夹中获取的资源)的摘录转移到另一个Plone实例; showstopper是:在导入期间,我的对象不会被写入。 这是我的导出脚本:

[transmogrifier]
pipeline =
    sitewalker
    xmlwalker
    uidextractor
    encapsulator
    manifestexporter
    fileexporter
    marshaller
    propertiesexporter
    commentsexporter
    datacorrector
    portletsexporter
    writer
    EXPORTING

[sitewalker]
blueprint = quintagroup.transmogrifier.sitewalker
path =
    folder1
    folder2

[xmlwalker]
blueprint = collective.transmogrifier.sections.xmlwalker

[uidextractor]
# my own section which parses the html text of the given fields,
# checks the href and src attributes for UIDs, and injects entries
# for the refered objects into the pipeline
blueprint = my.transmogrifier.uidextractor
inspect_fields =
    text
    description
    notes

[encapsulator]
blueprint = plone.app.transmogrifier.mimeencapsulator
mimetype = item/_mimetype
field = string:datafield

[manifestexporter]
blueprint = quintagroup.transmogrifier.manifestexporter

[fileexporter]
blueprint = quintagroup.transmogrifier.fileexporter

[marshaller]
blueprint = quintagroup.transmogrifier.marshaller

[propertiesexporter]
blueprint = quintagroup.transmogrifier.propertiesexporter

[commentsexporter]
blueprint = quintagroup.transmogrifier.commentsexporter

[datacorrector]
blueprint = quintagroup.transmogrifier.datacorrector
sources =
    marshall

[portletsexporter]
blueprint = quintagroup.transmogrifier.portletsexporter

[writer]
blueprint = quintagroup.transmogrifier.writer
context = directory
path = var/export/
prefix = structure

[EXPORTING]
blueprint = quintagroup.transmogrifier.logger
keys =
    _type
    _path

根据quintagroup.transmogrifier的默认导出和导入脚本,这是我的导入脚本:

[transmogrifier]
pipeline =
    reader
    pathfixer
    constructor
    schemaupdater
    datacorrector
    demarshaller
    uidupdater
    referencesimporter
    propertiesimporter
    commentsimporter
    portletsimporter
    printcounters
    IMPORTING

[reader]
blueprint = quintagroup.transmogrifier.reader
prefix = 
path = /path/to/var/export
context = directory
# unchanged entries I don't really understand:
.objects.xml = manifest
.marshall.xml = marshall
.properties.xml = propertymanager
.comments.xml = comments
.file-fields.xml = file-fields
.interfaces.xml = interfaces
.portlets.xml = portlets

[pathfixer]
blueprint = plone.app.transmogrifier.pathfixer
stripstring = Plone/
prependstring = 

[constructor]
blueprint = collective.transmogrifier.sections.constructor

[schemaupdater]
blueprint = plone.app.transmogrifier.atschemaupdater

[datacorrector]
blueprint = quintagroup.transmogrifier.datacorrector
type = import
sources =
    marshall

[fileimporter]
blueprint = quintagroup.transmogrifier.fileimporter

[demarshaller]
blueprint = quintagroup.transmogrifier.demarshaller

[uidupdater]
blueprint = plone.app.transmogrifier.uidupdater

[referencesimporter]
blueprint = quintagroup.transmogrifier.referencesimporter

[propertiesimporter]
blueprint = quintagroup.transmogrifier.propertiesimporter

[commentsimporter]
blueprint = quintagroup.transmogrifier.commentsimporter

[portletsimporter]
blueprint = quintagroup.transmogrifier.portletsimporter

[printcounters]
blueprint = collective.transmogrifier.sections.summary
count = true

[IMPORTING]
blueprint = quintagroup.transmogrifier.logger
keys = 
    _type
    _path

据我了解,reader出现在writer; marshaller出现demarshaller等。 但是,在导入时,对象实际上并未写入 数据库。用计数设备调整蓝图(在 我的包裹的add-info分支,我得到了以下内容 概述:

Items summary
~~~~~~~~~~~~~
[reader]:
  created:   714
[pathfixer]:
  got:         714
  forwarded:   714
  stripped:    390
[constructor]:
  got:            714
  missing-type:   714
  missing-info:   714
  forwarded:      714
[datacorrector]:
  got:         714
  forwarded:   714
[fileimporter]:
  got:          31
  forwarded:    31
[demarshaller]:
  got:          31
  forwarded:    31
[uidupdater]:
  got:          31
  forwarded:    31
[referencesimporter]:
  passed-through:    31
[printcounters]:
  passed-through:    31
[IMPORTING]:
  got:          31
  forwarded:    31

constructor没有对item做任何事情时,我会计算原因;显然constructor部分没有写任何东西,因为它不知道要创建的对象的类型。但不应该这样 信息是在某处创建的?!

(还有一个问题:显然只有fileimporter收到了 datacorrector传递了714的31个对象。但首先我会 喜欢看任何进口的东西。)

我做错了什么?

哦,collective.transmogrifier.sections的在线文档会很好;他们甚至缺乏文档字符串......

修改:我的启用计数的分叉在这里(分支add-info):

第二次修改

当我在IMPORTING之前移动constructer部分时,计数器输出为:

Items summary
~~~~~~~~~~~~~
[reader]:
  created:   714
[pathfixer]:
  got:         714
  forwarded:   714
  stripped:    390
[IMPORTING]:
  got:         714
  forwarded:   714
[constructor]:
  got:            714
  missing-type:   714
  missing-info:   714
  forwarded:      714
[datacorrector]:
  got:         714
  forwarded:   714
[fileimporter]:
  got:          31
  forwarded:    31
[demarshaller]:
  got:          31
  forwarded:    31
[uidupdater]:
  got:          31
  forwarded:    31
[referencesimporter]:
  passed-through:    31
[printcounters]:
  passed-through:    31

因此,collector仍无法找到_type信息。

第三次编辑:

我添加了一个小工具,可以打印关于找到的项目的简短信息(默认情况下每个部分的第1项; _path_type,其中包含值(如果存在)以及其他键的列表)。结果是:

[reader], item #1:
    _path=''
    other keys: _import_context (DirectoryImportContext)
[pathfixer], item #1:
    _path=''
    other keys: _import_context (DirectoryImportContext)
[pathfixer], item #2:
    _path=''
    other keys: _import_context (DirectoryImportContext)
2015-08-18 18:39:56 INFO IMPORTING _path=
[constructor], item #1:
    _path=''
    other keys: _import_context (DirectoryImportContext)
[reader], item #2:
    _path='some/archetypes/object/containing/a/video'
    other keys: _files (dict), _import_context (DirectoryImportContext)

确实在任何地方都没有_type个键,因此我需要一个提供它们的部分。

第四次编辑:

manifestimporter之前重新插入constructor后,我得到了:

[reader], item #1:
    _path=''
    other keys: _import_context (DirectoryImportContext)
[pathfixer], item #1:
    _path=''
    other keys: _import_context (DirectoryImportContext)
[pathfixer], item #2:
    _path=''
    other keys: _import_context (DirectoryImportContext)
2015-08-19 10:15:43 INFO IMPORTING _path=
[constructor], item #1:
    _path=''
    other keys: _import_context (DirectoryImportContext)
[manifestimporter], item #1:
    _path=''
    other keys: _import_context (DirectoryImportContext)
[reader], item #2:
    _path='    [reader], item #1:
    _path=''
    other keys: _import_context (DirectoryImportContext)
[pathfixer], item #1:
    _path=''
    other keys: _import_context (DirectoryImportContext)
[pathfixer], item #2:
    _path=''
    other keys: _import_context (DirectoryImportContext)
2015-08-19 10:15:43 INFO IMPORTING _path=
[constructor], item #1:
    _path=''
    other keys: _import_context (DirectoryImportContext)
[manifestimporter], item #1:
    _path=''
    other keys: _import_context (DirectoryImportContext)
[reader], item #2:
    _path='some/archetypes/object/containing/a/video'
    other keys: _files (dict), _import_context (DirectoryImportContext)
...
2015-08-19 10:15:44 INFO IMPORTING
Pipeline processing time: 00:00:00
         715 items were generated in source sections
           2 went through full pipeline
         713 were discarded in some section

manifestimporter部分不会转发任何先前的项目,因此reader中的所有项目都会被丢弃。

第五编辑: 尝试recommended way使用“站点配置导出步骤”;我编辑了默认的导出脚本并尝试了导出,但我得到了以下回溯:

Traceback (innermost last):
  Module ZPublisher.Publish, line 138, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 48, in call_object
  Module Products.GenericSetup.tool, line 598, in manage_exportSelectedSteps
  Module Products.GenericSetup.tool, line 1053, in _doRunExportSteps
  Module quintagroup.transmogrifier.exportimport, line 74, in exportSiteStructure
  Module collective.transmogrifier.utils, line 121, in constructPipeline
  Module quintagroup.transmogrifier.sitewalker, line 29, in __init__
TypeError: ('Could not adapt', {'manifestexporter': {'blueprint': 'quintagroup.transmogrifier.manifestexporter'}, 'transmogrifier': {'pipeline': '\nsitewalker\nuidextractor\npathfixer\nmanifestexporter\nfileexporter\nmarshaller\npropertiesexporter\ncommentsexporter\ndatacorrector\nportletsexporter\nwriter\nEXPORTING'}, 'uidextractor': {'blueprint': 'my.transmogrifier.uidextractor', 'trace-first': 'true', 'inspect_fields': '\ntext\ndescription\nnotes'}, 'sitewalker': {'blueprint': 'quintagroup.transmogrifier.sitewalker', 'start-path': '\nakademie/vortraege/d-02-verlegung-lektion-02-leitungsgraben', 'exclude-contained': 'false'}, 'xmlwalker': {'blueprint': 'collective.transmogrifier.sections.xmlwalker'}, 'encapsulator': {'blueprint': 'plone.app.transmogrifier.mimeencapsulator', 'mimetype': 'item/_mimetype', 'field': 'string:datafield'}, 'writer': {'blueprint': 'quintagroup.transmogrifier.writer', 'path': 'var/export/', 'prefix': '', 'context': 'tarball'}, 'commentsexporter': {'blueprint': 'quintagroup.transmogrifier.commentsexporter'}, 'pathfixer': {'blueprint': 'plone.app.transmogrifier.pathfixer', 'stripstring': 'unitracc/'}, 'echo': {'blueprint': 'visaplan.transmogrifier.echo'}, 'marshaller': {'blueprint': 'quintagroup.transmogrifier.marshaller'}, 'propertiesexporter': {'blueprint': 'quintagroup.transmogrifier.propertiesexporter'}, 'datacorrector': {'blueprint': 'quintagroup.transmogrifier.datacorrector', 'sources': '\nmarshall'}, 'breakpoint': {'blueprint': 'collective.transmogrifier.sections.breakpoint'}, 'EXPORTING': {'blueprint': 'quintagroup.transmogrifier.logger', 'keys': '\n_type\n_path'}, 'portletsexporter': {'blueprint': 'quintagroup.transmogrifier.portletsexporter'}, 'fileexporter': {'blueprint': 'quintagroup.transmogrifier.fileexporter'}}, <InterfaceClass zope.annotation.interfaces.IAnnotations>)

我的uidexporter部分是否包括在内并不重要。

第6编辑:

以下是我用于站点配置导出步骤的当前导出配置文件:

[transmogrifier]
pipeline =
    sitewalker
    manifestexporter
    fileexporter
    marshaller
    propertiesexporter
    commentsexporter
    datacorrector
    portletsexporter
    writer
    EXPORTING

[sitewalker]
blueprint = quintagroup.transmogrifier.sitewalker
exclude-contained = false
start-path =
    Plone/some/existing/structure

[manifestexporter]
blueprint = quintagroup.transmogrifier.manifestexporter

[fileexporter]
blueprint = quintagroup.transmogrifier.fileexporter

[marshaller]
blueprint = quintagroup.transmogrifier.marshaller

[propertiesexporter]
blueprint = quintagroup.transmogrifier.propertiesexporter

[commentsexporter]
blueprint = quintagroup.transmogrifier.commentsexporter

[datacorrector]
blueprint = quintagroup.transmogrifier.datacorrector
sources =
    marshall

[portletsexporter]
blueprint = quintagroup.transmogrifier.portletsexporter

[writer]
blueprint = quintagroup.transmogrifier.writer
context = tarball
path = var/export/
prefix =

[EXPORTING]
blueprint = quintagroup.transmogrifier.logger
keys =
    _type
    _path

第7次修改: 一个简短的信息reader需要哪种数据才能使constructor创建对象,以及导出管道的哪一部分(了解必要的选项)可以获得150点声望点; - )

1 个答案:

答案 0 :(得分:0)

从比较到quintagroup.transmogrifier's import.cfg您缺少管道中的显示导入部分。他们的管道上写着:

pipeline =
    reader
    manifestimporter
    constructor
    datacorrector
    fileimporter
    demarshaller
    referencesimporter
    propertiesimporter
    commentsimporter
    portletsimporter
    IMPORTING