Bugfix ie11 qui créé un bug dans Plinn… Quelle chienlit IE…
[Plinn.git] / _zctl / folders2BTrees.py
1 # -*- coding: utf-8 -*-
2 from argparse import ArgumentParser
3 import os.path
4 from Acquisition import aq_base
5 from zope.site.hooks import setSite
6 from Products.CMFCore.CMFCatalogAware import CMFCatalogAware
7 import transaction
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
13
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()
24
25
26
27
28
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)
34 setSite(portal)
35
36 recurseMigrateFolders(portal)
37
38 if not args.dry_run :
39 transaction.commit()