Plone 4.0.7 中 FileField 到 BlobField 迁移期间 reindexObject 失败
我正在尝试从 plone 3.3.5 迁移到 plone 4.0.7,但我陷入了将所有 FileField 转换为 BlobField 的步骤。
Plone 升级脚本成功转换了所有本机 FileField,但我有几个必须手动转换的基于 AT 的自定义类。我尝试了两种进行转换的方法,这导致我遇到同样的错误。
按照 Plone 迁移指南 和 源代码示例
将所有 FileField 重命名为 blob 字段,然后运行脚本:
从 AccessControl.SecurityManagement 导入 newSecurityManager 从 AccessControl 导入 getSecurityManager 从 Products.CMFCore.utils 导入 getToolByName 从 zope.app.component.hooks 导入 setSite 从 Products.contentmigration.migrator 导入 BaseInlineMigrator 从 Products.contentmigration.walker 导入 CustomQueryWalker 从 plone.app.blob.field 导入 BlobField 管理员=app.acl_users.getUserById(“管理员”) newSecurityManager(无,管理员) 门户=app.plone 设置站点(门户) def find_all_types_fields(portal_catalog, type_instance_to_search): 输出={} 搜索=[] 对于 Catalog() 中的 k: kobj = k.getObject() 如果搜索到 kobj.__class__.__name__ : 继续 searched.append(kobj.__class__.__name__) 对于 kobj.schema.fields() 中的字段: if isinstance(字段, type_instance_to_search): 如果输出中有 kobj.__class__.__name__ : 输出[kobj.__class__.__name__].append(field.__name__) 别的: 输出[kobj.__class__.__name__] = [field.__name__] 返回输出 def Produce_migrator(field_map): source_class = field_map.keys()[0] 字段={} 对于 field_map.values()[0] 中的 x:fields[x] = None 类 FileBlobMigrator(BaseInlineMigrator): '''将 ExtensionBlobField(仍然是 FileField)迁移到 BlobField''' src_portal_type = 源类 src_meta_type = 源类 fields_map = 字段 def migrate_data(自身): '''未完成''' 对于 self.fields_map.keys() 中的 k: #print“检查属性” #导入pdb; pdb.set_trace() #if hasattr(self.obj, k): 如果 k 在 self.obj.schema.keys() 中: print("***转换属性:", k) 字段 = self.obj.getField(k).get(self.obj) mutator = self.obj.getField(k).getMutator(self.obj) 突变体(字段) def last_migrate_reindex(self): '''未完成''' self.obj.reindexObject() 返回 FileBlobMigrator def Consumer_migrator(portal_catalog, 迁移器): walker = CustomQueryWalker(portal_catalog, 迁移器, full_transaction=True) transaction.savepoint(乐观=True) walker_status = walker.go() 返回 walker.getOutput() def migrate_blobs(目录,migrate_type): all_fields = find_all_types_fields(目录, migrate_type) 导入pdb; pdb.set_trace() 对于 [ {k : all_fields[k]} 中的 k 对于 all_fields] 中的 k: 迁移器 = Produce_migrator(k) 打印 Consumer_migrator(目录,迁移器) 目录 = getToolByName(portal, 'portal_catalog') migrate_blobs(目录,BlobField)
问题发生在 self.obj.reindexObject() 行上,我收到以下回溯:
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,也许与此有关?
I'm trying to migrate from plone 3.3.5 to plone 4.0.7 and I'm stuck on a step that converts all the FileFields to BlobFields.
Plone upgrade script successfully converts all native FileFields but I have several custom AT-based classes which have to be converted manually. I've tried two ways of doing the conversion which leads me to the same error.
Using schemaextender as outlined in Plone migration guide and a source code example
Renaming all FileFields to blob fields and then running this script:
from AccessControl.SecurityManagement import newSecurityManager from AccessControl import getSecurityManager from Products.CMFCore.utils import getToolByName from zope.app.component.hooks import setSite from Products.contentmigration.migrator import BaseInlineMigrator from Products.contentmigration.walker import CustomQueryWalker from plone.app.blob.field import BlobField admin=app.acl_users.getUserById("admin") newSecurityManager(None, admin) portal = app.plone setSite(portal) def find_all_types_fields(portal_catalog, type_instance_to_search): output = {} searched = [] for k in catalog(): kobj = k.getObject() if kobj.__class__.__name__ in searched: continue searched.append(kobj.__class__.__name__) for field in kobj.schema.fields(): if isinstance(field, type_instance_to_search): if kobj.__class__.__name__ in output: output[kobj.__class__.__name__].append(field.__name__) else: output[kobj.__class__.__name__] = [field.__name__] return output def produce_migrator(field_map): source_class = field_map.keys()[0] fields = {} for x in field_map.values()[0]: fields[x] = None class FileBlobMigrator(BaseInlineMigrator): '''Migrating ExtensionBlobField (which is still a FileField) to BlobField''' src_portal_type = source_class src_meta_type = source_class fields_map = fields def migrate_data(self): '''Unfinished''' for k in self.fields_map.keys(): #print "examining attributes" #import pdb; pdb.set_trace() #if hasattr(self.obj, k): if k in self.obj.schema.keys(): print("***converting attribute:", k) field = self.obj.getField(k).get(self.obj) mutator = self.obj.getField(k).getMutator(self.obj) mutator(field) def last_migrate_reindex(self): '''Unfinished''' self.obj.reindexObject() return FileBlobMigrator def consume_migrator(portal_catalog, migrator): walker = CustomQueryWalker(portal_catalog, migrator, full_transaction=True) transaction.savepoint(optimistic=True) walker_status = walker.go() return walker.getOutput() def migrate_blobs(catalog, migrate_type): all_fields = find_all_types_fields(catalog, migrate_type) import pdb; pdb.set_trace() for k in [ {k : all_fields[k]} for k in all_fields]: migrator = produce_migrator(k) print consume_migrator(catalog, migrator) catalog = getToolByName(portal, 'portal_catalog') migrate_blobs(catalog, BlobField)
The problem occurs on self.obj.reindexObject() line where I receive the following traceback:
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:
If I remove the line that triggers reindexing, the conversion completes successfully, but if I try to manually reindex catalog later, every object that's been converted can no longer be found, and I'm a bit at loss of what to do now.
The site has LinguaPlone installed, maybe it has something to do with this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一种选择是在不调用 reindexObject() 的情况下运行迁移,并在迁移后在目录 ZMI Advanced 选项卡中执行“清除并重建”。
One option would be to run the migration without the reindexObject() call and do a "Clear and Rebuild" in the catalog ZMI Advanced tab after migrating.