Exemple #1
0
    def __init__(self,
                 portal,
                 migrator,
                 src_portal_type=None,
                 dst_portal_type=None,
                 query={},
                 callBefore=None,
                 **kwargs):
        """Set up the walker. See contentmigration.basemigrator.walker for details.

        The 'query' parameter can be used to pass a dict with custom catalog
        query parameters. Note that portal_type and meta_type will be set
        based on src_portal_type or, if given, the src_portal_type in the
        migrator.

        The 'callBefore' parameter can be used to pass a function that will
        be called before each item is migrated. If it returns False, the item
        will be skipped. It should have the signature:

            callBefore(oldObject, **kwargs)

        The kwargs passed to this constructor will be passed along to the
        test function.
        """
        CatalogWalker.__init__(self,
                               portal,
                               migrator,
                               src_portal_type=src_portal_type,
                               dst_portal_type=dst_portal_type,
                               **kwargs)
        self.additionalQuery.update(query)
        self.callBefore = callBefore
        self.kwargs = kwargs
Exemple #2
0
def upgrade_from_16_to_20(context):
    site = getToolByName(context, 'portal_url').getPortalObject()
    types = dict(ProjectFolder='Folder', CustomerFolder='Folder')

    class ProjectFolderMigrator(ATFolderMigrator):
        src_portal_type = src_meta_type = 'ProjectFolder'
        dst_portal_type = dst_meta_type = 'Folder'
        new_allowed = ('Project', )

        def migrate_typerestriction(self):
            constraints = ISelectableConstrainTypes(self.new)
            constraints.setConstrainTypesMode(ENABLED)
            constraints.setImmediatelyAddableTypes(self.new_allowed)
            constraints.setLocallyAllowedTypes(self.new_allowed)

    projectfolders = CatalogWalker(site, ProjectFolderMigrator)
    projectfolders.go()

    class CustomerFolderMigrator(ProjectFolderMigrator):
        src_portal_type = src_meta_type = 'CustomerFolder'
        dst_portal_type = dst_meta_type = 'Folder'
        new_allowed = ('Customer', )

    customerfolders = CatalogWalker(site, CustomerFolderMigrator)
    customerfolders.go()
def migrate_atdoc_openpage(self):
    catalog = getToolByName(self, 'portal_catalog')
    portal = getToolByName(self, 'portal_url').getPortalObject()
    out = []

    migrator = OpenPageMigrator
    out.append('*** Migrating %s to %s ***\n' % (migrator.src_portal_type,
                                                 migrator.dst_portal_type))
    try:
        w = CatalogWalker(migrator, portal) # ATCT-0.2
    except AttributeError:
        w = CatalogWalker(portal, migrator) # ATCT-1.0
    w_result = w.go()
    if type(w_result) == type(''):
        out.append(w_result) # ATCT-0.2
    else:
        out.append('%s Migrated\n' % migrator.src_portal_type)

    if getattr(w, 'counter', 0):
        wf = getToolByName(self, 'portal_workflow')
        count = wf.updateRoleMappings()
        out.append('Workflow: %d object(s) updated.' % count)

        catalog.refreshCatalog(clear=1)
        out.append('Portal catalog updated.')

    ttool = getToolByName(self, 'portal_types')
    doc_fti = ttool.getTypeInfo('Document')
    if doc_fti.Metatype() != 'OpenPage':
        if ttool.getTypeInfo('ATDocument') is not None:
            ttool._delObject('ATDocument')
        get_transaction().commit(1)
        atct_tool = getToolByName(self, 'portal_atct')
        atct_tool._changePortalTypeName('Document', 'ATDocument',
                                        global_allow=0,
                                        title='AT Document')
        get_transaction().commit(1)
        atct_tool._changePortalTypeName('OpenPage', 'Document',
                                        global_allow=1,
                                        title='Page')
        out.append('Document types switched')

    # fix up any OpenPages that are now assoc w/ ATDocument
    brains = catalog(portal_type="ATDocument", meta_type="OpenPage")
    for b in brains:
        pg = b.getObject()
        pg.portal_type = 'Document'
        pg.reindexObject()

    return '\n'.join(out)
def upgrade_from_16_to_20(context):
    site = getToolByName(context, 'portal_url').getPortalObject()
    types = dict(ProjectFolder='Folder', CustomerFolder='Folder')

    class ProjectFolderMigrator(ATFolderMigrator):
        src_portal_type = src_meta_type = 'ProjectFolder'
        dst_portal_type = dst_meta_type = 'Folder'
        new_allowed = ('Project', )

        def migrate_typerestriction(self):
            constraints = ISelectableConstrainTypes(self.new)
            constraints.setConstrainTypesMode(ENABLED)
            constraints.setImmediatelyAddableTypes(self.new_allowed)
            constraints.setLocallyAllowedTypes(self.new_allowed)

    projectfolders = CatalogWalker(site, ProjectFolderMigrator)
    projectfolders.go()

    class CustomerFolderMigrator(ProjectFolderMigrator):
        src_portal_type = src_meta_type = 'CustomerFolder'
        dst_portal_type = dst_meta_type = 'Folder'
        new_allowed = ('Customer', )

    customerfolders = CatalogWalker(site, CustomerFolderMigrator)
    customerfolders.go()
Exemple #5
0
 def __init__(self, portal, migrator, src_portal_type=None, dst_portal_type=None,
                 query={}, callBefore=None, **kwargs):
     """Set up the walker. See contentmigration.basemigrator.walker for details.
     
     The 'query' parameter can be used to pass a dict with custom catalog
     query parameters. Note that portal_type and meta_type will be set
     based on src_portal_type or, if given, the src_portal_type in the
     migrator. 
     
     The 'callBefore' parameter can be used to pass a function that will
     be called before each item is migrated. If it returns False, the item
     will be skipped. It should have the signature:
     
         callBefore(oldObject, **kwargs)
         
     The kwargs passed to this constructor will be passed along to the
     test function.
     """
     CatalogWalker.__init__(self, portal, migrator,
                            src_portal_type=src_portal_type,
                            dst_portal_type=dst_portal_type, **kwargs)
     self.additionalQuery.update(query)
     self.callBefore = callBefore
     self.kwargs = kwargs
def migrate(portal, migrator):
    """ Run migration
    """
    walker = CatalogWalker(portal, migrator)
    return walker.go()
def migrate(portal, migrator):
    walker = CatalogWalker(portal, migrator)
    return walker.go()
def migrate(portal, migrator):
    """return a CatalogWalker instance in order
    to have its output after migration"""
    walker = CatalogWalker(portal, migrator)()
    return walker
Exemple #9
0
def migrate_frontpage(portal):
    walker = CatalogWalker(portal, FrontpageMigrator)
    walker.go()