特定文件夹的内容迁移
我有一个脚本,将 Image 迁移到我的 Plone 实例的自定义类型。它的部分代码示例如下所示:
class ImagesToPhotosMigrator(InplaceATItemMigrator):
src_portal_type = 'Image'
src_meta_type = 'ATBlob'
dst_portal_type = 'Photo'
dst_meta_type = 'Photo'
def last_migrate_reindex(self):
self.new.reindexObject(idxs=['object_provides', 'portal_type',
'Type', 'UID'])
fields_map = {
}
def getImagesToPhotosMigrationWalker(self):
return getMigrationWalker(self, migrator=ImagesToPhotosMigrator)
def migrateImages(self):
walker = getImagesToPhotosMigrationWalker(self)
walker.go()
return walker.getOutput()
脚本有效,但我希望迁移仅发生在特定文件夹中,例如 /my-folder
,在脚本中添加什么?
I have a script, migrating Image to a custom type, for my Plone instance. Its partial code sample looks like this:
class ImagesToPhotosMigrator(InplaceATItemMigrator):
src_portal_type = 'Image'
src_meta_type = 'ATBlob'
dst_portal_type = 'Photo'
dst_meta_type = 'Photo'
def last_migrate_reindex(self):
self.new.reindexObject(idxs=['object_provides', 'portal_type',
'Type', 'UID'])
fields_map = {
}
def getImagesToPhotosMigrationWalker(self):
return getMigrationWalker(self, migrator=ImagesToPhotosMigrator)
def migrateImages(self):
walker = getImagesToPhotosMigrationWalker(self)
walker.go()
return walker.getOutput()
The script works, but I want the migration only happens in a specific folder, say /my-folder
, what to add in the script?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该指定您引用 Products.contentmigration,因为它没有隐含在单词中“内容迁移”(最近迁移的种类比代码行还要多)。无论如何,这里是您的解决方案(
CustomQueryWalker
是关键):请注意,查询参数是目录查询,因此您可以指定路径、portal_type 或目录中的任何索引。
You should have specified that you refer to Products.contentmigration, cause it's not implicit in the words "content migration" (lately there are more kind of migrations than lines of code). Anyway, here your solution (
CustomQueryWalker
is the key):Note that the query parameter is a catalog query, therefore you can specify the path, the portal_type or any index in your catalog.