1 # -*- coding: utf-8 -*-
2 from argparse
import ArgumentParser
4 from Acquisition
import aq_base
5 from zope
.site
.hooks
import setSite
6 from Products
.CMFCore
.CMFCatalogAware
import CMFCatalogAware
8 from OFS
.interfaces
import IObjectManager
9 from zope
.interface
import providedBy
10 from Products
.Plinn
.Folder
import PlinnFolder
11 from Products
.Plinn
.HugePlinnFolder
import HugePlinnFolder
12 from Products
.Plinn
.migration
.folder
import migrateFolder
14 def recurseMigrateFolders(parent
) :
15 for child
in parent
.objectValues() :
16 if IObjectManager
.providedBy(child
) :
17 recurseMigrateFolders(child
)
18 if isinstance(child
, PlinnFolder
) and \
19 not isinstance(child
, HugePlinnFolder
) :
20 migrated
= migrateFolder(child
, parent
)
21 # pseudo _finishContrsuction to preserve dates.
22 migrated
._setPortalTypeName
('Huge Plinn Folder')
23 migrated
.reindexObject()
29 parser
= ArgumentParser(description
="Convert all regular Plinn Folder to Huge Plinn Folder")
30 parser
.add_argument('portal_path')
31 parser
.add_argument('--dry-run', action
='store_true')
32 args
= parser
.parse_args()
33 portal
= app
.unrestrictedTraverse(args
.portal_path
)
36 recurseMigrateFolders(portal
)