Some changes need to be done to the serialized data when this tool is used for a migration (e.g. from Plone 4 to Plone 5 or 6) and/or from Archetypes to Dexterity.
To make this easier we could add a checkbox (checked by default) "Modify data for migrations".
If this is checked then some modifiers will run during export.
These could include:
Drop unused data
Some data that restapi includes is useless for migrations. E.g. @components, next_item, previous_item.
Drop all Relations
Relations are migrated seperately. haveing them in the data will mess up the site. This is probably easiest done by switching on custom serializers for IReferenceField (AT) and IRelationChoice and IRelationList (DX) that return none.
Change default-fieldnames (AT to DX):
# Migrate AT to DX
if item.get("expirationDate"):
item["expires"] = item["expirationDate"]
if item.get("effectiveDate"):
item["effective"] = item["effectiveDate"]
if item.get("excludeFromNav"):
item["exclude_from_nav"] = item["excludeFromNav"]
if item.get("subject"):
item["subjects"] = item["subject"]
Fix datetime data
see #10
Fix issue with AT Text fields
TextField-export in Archetypes: Inspecting the AT-schema and applying a change for all Textfields if the RichtextWidget is not used (which means the field is probably Text in DX and not RichText).
# In Archetypes Text is handled the same as RichText
if isinstance(item.get("description", None), dict):
item[fieldname] = item[fieldname]["data"]
if isinstance(item.get('rights', None), dict):
item['rights'] = item['rights']['data']
Fix collection-criteria
Some criteria have changed, e.g.
query = item.pop("query", [])
for crit in query:
if crit["o"].endswith("relativePath") and crit["v"] == "..":
crit["v"] = "..::1"
if crit["i"] == "portal_type" and crit["o"].endswith("selection.is"):
crit["o"] = "plone.app.querystring.operation.selection.any"
Some changes need to be done to the serialized data when this tool is used for a migration (e.g. from Plone 4 to Plone 5 or 6) and/or from Archetypes to Dexterity.
To make this easier we could add a checkbox (checked by default) "Modify data for migrations".
If this is checked then some modifiers will run during export.
These could include:
Drop unused data
Some data that restapi includes is useless for migrations. E.g.
@components
,next_item
,previous_item
.Drop all Relations
Relations are migrated seperately. haveing them in the data will mess up the site. This is probably easiest done by switching on custom serializers for
IReferenceField
(AT) andIRelationChoice
andIRelationList
(DX) that return none.Change default-fieldnames (AT to DX):
Fix datetime data
see #10
Fix issue with AT Text fields
TextField-export in Archetypes: Inspecting the AT-schema and applying a change for all Textfields if the RichtextWidget is not used (which means the field is probably Text in DX and not RichText).
Fix collection-criteria
Some criteria have changed, e.g.
Fix image links and scales
Use the code in https://github.com/collective/collective.migrationhelpers/blob/master/src/collective/migrationhelpers/images.py to fix links to images and make them editable in TinyMCE.