Back to index

plone3  3.1.7
migrate_atdoc_wickeddoc.py
Go to the documentation of this file.
00001 from Products.ATContentTypes.migration.walker import CatalogWalker
00002 from wicked.at.migration.migrator import WickedDocMigrator
00003 from Products.CMFCore.utils import getToolByName
00004 
00005 def migrate_atdoc_wickeddoc(self):
00006     catalog = getToolByName(self, 'portal_catalog')
00007     portal = getToolByName(self, 'portal_url').getPortalObject()
00008     out = []
00009 
00010     migrator = WickedDocMigrator
00011     out.append('*** Migrating %s to %s ***\n' % (migrator.src_portal_type,
00012                                                  migrator.dst_portal_type))
00013     try:
00014         w = CatalogWalker(migrator, portal) # ATCT-0.2
00015     except AttributeError:
00016         w = CatalogWalker(portal, migrator) # ATCT-1.0
00017     w_result = w.go()
00018     if type(w_result) == type(''):
00019         out.append(w_result) # ATCT-0.2
00020     else:
00021         out.append('%s Migrated\n' % migrator.src_portal_type)
00022 
00023     wf = getToolByName(self, 'portal_workflow')
00024     count = wf.updateRoleMappings()
00025     out.append('Workflow: %d object(s) updated.' % count)
00026 
00027     catalog.refreshCatalog(clear=1)
00028     out.append('Portal catalog updated.')
00029 
00030     ttool = getToolByName(self, 'portal_types')
00031     doc_fti = ttool.getTypeInfo('Document')
00032     if doc_fti.Metatype() != 'WickedDoc':
00033         atct_tool = getToolByName(self, 'portal_atct')
00034         get_transaction().commit(1)
00035         atct_tool._changePortalTypeName('Document', 'ATDocument',
00036                                         global_allow=0,
00037                                         title='AT Document')
00038         get_transaction().commit(1)
00039         atct_tool._changePortalTypeName('WickedDoc', 'Document',
00040                                         global_allow=1,
00041                                         title='Page')
00042         out.append('Document types switched')
00043 
00044     return '\n'.join(out)