Plone 5 Custom Archetype to Dexterity using @@custom_migration does not migrate

I have found that the converting the default types from Archetypes to Dexterity was rather painless. The conversion of custom types appears painless at the surface, but it just does not work as advertised. I am attempting to use the @@custom_migration form. I have created my Dexterity Type. Everything maps one-to-one. I had already converted the default types a couple of weeks ago but left the custom type until later. Partial migrations are said to be supported.

The docs that I am following are here:
http://docs.plone.org/external/plone.app.contenttypes/docs/README.html#migrating-custom-content

First when I browsed to the @@custom_migration form, I got an error complaining that it couldn't get the Schema for the Archetypes based types to build the form.

I imported all steps for Archetypes Content Types using portal_setup.

The form loaded. Then I mapped my custom type fields.

I ran the test, and it failed with red exclamation point. I saw in the log that it was complaining about not being able to find the dexterity folder type, so I went to portal_setup and imported plone.app.dexterity profile. Then I ran the test with a success green checkmark.

When I clicked "Migrate" the log indicated that it all migrated except that it ran into an error when it appears it might try to load the @@custom_migration form again. Now the error is that it can't iterate over the schema fields again. Although the log indicated Migrating was successful, nothing has actually been migrated. All it did was try to migrate the types that I had selected as "Do not migrate" as now I cannot edit any of the "default" items.

Has anyone else encountered these errors when converting custom Archetypes to Dexterity? Is there something that does not sound correct about the procedure that I described above? Any help is greatly appreciated. I am at my wit's end here.

Update:

Whenever I add "Archetypes Content Types for Plone" via portal_setup, I get the error: ComponentLookupError: (, 'Folder') when I attempt to migrate.

Whenever I add "plone.app.dexterity:testing", I get the successful Test configuration but then run into the error for Archetypes: AttributeError: schema in template "repeat="field python: view.getFieldsForATType(at_type)">.

It seems that the two profiles negate each other, but both have to work for the @@custom_migration form to work.

I have fixed the problem. I rolled back the site to last night's backup (before doing anything in portal_setup). Instead I traced the custom_migration.py file in plone.app.contenttypes and added some logging to discover that it was failing not on my custom type but on the old Archetype-based Folder type. All folders had been replaced by Dexterity already, so that was odd. I added a try/except for getting old types to present since I really only wanted it for my custom type anyway.

Line 176 custom_migration.py:

   ` logger.info( 'getting fields for type "%s"' % typename )
    try:
        for field_name in obj.schema._fields:
            field = obj.schema._fields[field_name]
            if not field.getName() in self.at_metadata_fields:
                translated_label = translate(field.widget.label)
                results.append(
                    {'id': field.getName(),
                     'title': '%s (%s)' % (translated_label, field.getType()),
                     'type': field.getType()})
    except:
        logger.info( 'Skipped type "%s"' % typename )`

Then everything worked perfectly.

I run into the same error. Here is the extra info that might be helpful.

I apply the above try/except codes to make custom_migration template successfully appear.

When I run atct_migrator, the template page says there are 770 Folder items to be migrated. However I see 788 Folder items after the migration via the search_all template. So it seems to imply 18 ATFolder items are not migrated. That's odd and I don't know how to debug to identify them.

@jrobinson Can you specify how it failed, do you have a traceback or log-output? I don't really want to add a blind try/except around that code.

The migration-forms use the catalog to find the content. Since Archetyoes types have a different meta_type than Dexterity content, this is thew way that the migration finds it. Folders have ATFolder, Documents have ATDocument, Files and Images have ATBlob.
You can inspect this index in http://localhost:8080/Plone/portal_catalog/Indexes/meta_type/manage_browse and find any content that is not migrated.
The default Dexterity types (from plone.app.contenttypes) are all Dexterity Container (Folder) or Dexterit Item (everything else). Your catalog needs to be correct for the migration to work well.

1 Like

From ZMI /portal_catalog/Indexes/meta_type I see ATBTreeFolder and 18 items, identical to my issue. Thanks for the great hint! I have the confidence that we don't need the try/except clause.

Still it would be nice to know what broke in the for field_name in obj.schema._fields: loop.