Migration 在Plone 4.0.7中从FileField迁移到BlobField期间,reindexObject失败
我正试图从plone 3.3.5迁移到plone 4.0.7,但我遇到了一个难题,那就是将所有文件字段转换为BlobFields Plone升级脚本成功地转换了所有本机文件字段,但我有几个自定义的基于AT的类,它们必须手动转换。我尝试了两种转换方法,这导致了相同的错误Migration 在Plone 4.0.7中从FileField迁移到BlobField期间,reindexObject失败,migration,plone,filefield,reindex,Migration,Plone,Filefield,Reindex,我正试图从plone 3.3.5迁移到plone 4.0.7,但我遇到了一个难题,那就是将所有文件字段转换为BlobFields Plone升级脚本成功地转换了所有本机文件字段,但我有几个自定义的基于AT的类,它们必须手动转换。我尝试了两种转换方法,这导致了相同的错误 如和中所述使用SchemaXtender 将所有文件字段重命名为blob字段,然后运行此脚本: 从AccessControl.SecurityManagement导入新闻安全管理器 从AccessControl导入getSecur
从AccessControl.SecurityManagement导入新闻安全管理器
从AccessControl导入getSecurityManager
从Products.CMFCore.utils导入getToolByName
从zope.app.component.hooks导入设置位置
从Products.contentmigration.migrator导入BaseInlineMigrator
从Products.contentmigration.walker导入CustomQueryWalker
从plone.app.blob.field导入BlobField
admin=app.acl\u users.getUserById(“admin”)
新闻安全管理器(无,管理)
portal=app.plone
设置位置(入口)
def查找所有类型字段(门户目录、类型实例到搜索):
输出={}
搜索=[]
对于目录()中的k:
kobj=k.getObject()
如果搜索到kobj.\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
持续
searched.append(kobj.\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
对于kobj.schema.fields()中的字段:
如果isinstance(字段,键入要搜索的实例):
如果输出中有kobj.\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
输出[kobj.\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
其他:
输出[kobj.\uuuuuuu类\uuuuuuuu名\uuuuuuuu]=[field.\uuuuuuuuuu名]
返回输出
def生产迁移器(现场地图):
source\u class=field\u map.keys()[0]
字段={}
对于字段中的x_map.values()[0]:字段[x]=无
类FileBlobMigrator(BaseInlineMigrator):
''正在将ExtensionBlobField(仍然是一个文件字段)迁移到BlobField''
src\u portal\u type=源类
src_meta_type=源类
字段\映射=字段
def迁移_数据(自身):
“未完成”
对于self.fields\u map.keys()中的k:
#打印“检查属性”
#进口pdb;pdb.set_trace()
#如果hasattr(self.obj,k):
如果self.obj.schema.keys()中有k:
打印(“***转换属性:”,k)
field=self.obj.getField(k).get(self.obj)
mutator=self.obj.getField(k).getMutator(self.obj)
变异因子(字段)
定义上次迁移重新索引(自):
“未完成”
self.obj.reindexObject()
返回文件blobmigrator
def consume_migrator(入口目录,migrator):
walker=CustomQueryWalker(门户目录、迁移器、完整事务=True)
transaction.savepoint(乐观=真)
walker_status=walker.go()
return walker.getOutput()
def migrate_blob(目录,迁移类型):
所有字段=查找所有类型字段(目录、迁移类型)
进口pdb;pdb.set_trace()
对于k in[{k:all_fields[k]}对于k in[{k:all_fields[k]]:
migrator=product\u migrator(k)
打印使用迁移器(目录,迁移器)
catalog=getToolByName(门户,'portal\u catalog')
迁移\u blob(目录,BlobField)
2011-08-09 17:21:12 ERROR Zope.UnIndex KeywordIndex: unindex_object could not remove documentId -1945041983 from index object_provides. This should not happen.
Traceback (most recent call last):
File "/home/alex/projects/plone4/eggs/Zope2-2.12.18-py2.6-linux-x86_64.egg/Products/PluginIndexes/common/UnIndex.py", line 166, in removeForwardIndexEntry indexRow.remove(documentId)
KeyError: -1945041983
> /home/alex/projects/plone4/eggs/Zope2-2.12.18-py2.6-linux-x86_64.egg/Products/PluginIndexes/common/UnIndex.py(192)removeForwardIndexEntry()
191 str(documentId), str(self.id)),
--> 192 exc_info=sys.exc_info())
193 else:
如果我删除触发重新索引的行,转换将成功完成,但如果我稍后尝试手动重新索引目录,则无法再找到已转换的每个对象,我现在有点不知所措
站点已安装LinguaPlone,可能与此有关?一个选项是在不调用reindexObject()的情况下运行迁移,并在迁移后在catalog ZMI Advanced选项卡中执行“清除并重建”。是,我运行了它,完成后,无法使用portal_catalog搜索所有修改的对象。您确定是“清除并重建”而不是“更新目录”吗?清除和重建应该从零开始,因此不会受到任何问题的影响,如您问题中报告的问题。好吧,似乎我有一个bug触发了另一个bug,portal_catalog工作得很好。这两种情况下,只是代码中的一条语句向它传递了错误的搜索参数。在我重新索引脚本后,它运行良好,帮助我找到了另一个bug。