首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Plone: collective.transmogrifier.sections.constructor在导入时不会写入对象

Plone: collective.transmogrifier.sections.constructor在导入时不会写入对象
EN

Stack Overflow用户
提问于 2015-08-13 16:00:08
回答 1查看 260关注 0票数 8

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

代码语言:javascript
复制
[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的默认导出和导入脚本,下面是我的导入脚本:

代码语言:javascript
复制
[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分支中)调整蓝图,我得到了以下概述:

代码语言:javascript
复制
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部分时,计数器输出是:

代码语言:javascript
复制
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信息。

第三版:

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

代码语言:javascript
复制
[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密钥,所以我需要一个提供它们的部分。

第4版:

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

代码语言:javascript
复制
[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中的所有项都会被丢弃。

5编辑:尝试使用“站点配置导出步骤”();我编辑了默认导出脚本并尝试了导出,但得到了以下跟踪:

代码语言:javascript
复制
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编辑:

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

代码语言:javascript
复制
[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个信誉点;-)

EN

回答 1

Stack Overflow用户

发布于 2015-08-18 18:06:22

通过与Quintagroup.Transmogrifier的import.cfg的比较,您在管道中缺少了一个显能者部分。他们的管道上写着:

代码语言:javascript
复制
pipeline =
    reader
    manifestimporter
    constructor
    datacorrector
    fileimporter
    demarshaller
    referencesimporter
    propertiesimporter
    commentsimporter
    portletsimporter
    IMPORTING
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31993175

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档