I would migrate a Plone 4 Site to Plone 6 with Classic UI. The old Plone 4 is mounted via an extra mountpoint. in the export json is see the id field and the parent id field with the full path
@id "http://127.0.0.1:8080/mount/site/de/...."
i would like to import all data in a regular installation without an extra mountpoint. the ids should be switched to
http://127.0.0.1:8080/site/de/....
where is the right place to modify the ids? in the export or the import? should i use the global_dict_hook ?
My first attempt with collective.exportimport, sorry for my stupid question.
Update: i fix it in the custom import script
def global_dict_hook(self, item):
# fix mount point
item["@id"] = item["@id"].replace("/mount/site","/site")
item["parent"]["@id"] = item["parent"]["@id"].replace("/mount/site","/site")
# fix wrong id
item["@id"] = item["@id"].replace("%20","-")
item["parent"]["@id"] = item["parent"]["@id"].replace("%20","-")
# fix empty creators
creators = item["creators"]
new_creators = []
for creator in creators:
if len(creator) > 0:
new_creators.append(creator)
if len(new_creators) == 0:
new_creators.append("admin")
item["creators"] = new_creators
return item
This is a general question: fix things on export or import?
My general approach is fixing things at import time and leave the export of the source system as-is.
You only want to maintain changes only in one place…you usually work on the migration import in order to get the data right…so I would recommend making such changes always on the import side.
you need to change the parent’s id of the item too !
as a convenience we’ve saved the original path too and stored it in some “import” annotation on the new object (not covered in this post). but that’s up to you
EDIT: of course you need to be careful, when replacing the path … better parse the url with urllib before and catch special cases like /mountpoint/plonesite/subfolder/mountpoint/ in your replace.
EDIT 2: I should have read your post till the end you already provided the solution