From 0736d4eec98fae4188e3043a635de556dc4610e7 Mon Sep 17 00:00:00 2001 From: Thibaut Born Date: Fri, 1 Sep 2023 10:46:15 +0200 Subject: [PATCH] migrate portlets on site root context: migration only checked on uid, which left out the portal root --- src/collective/exportimport/export_other.py | 11 ++++++++++- src/collective/exportimport/import_other.py | 6 +++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/collective/exportimport/export_other.py b/src/collective/exportimport/export_other.py index bc85da41..ded77b94 100644 --- a/src/collective/exportimport/export_other.py +++ b/src/collective/exportimport/export_other.py @@ -639,12 +639,16 @@ def all_portlets(self): self.results = [] portal = api.portal.get() portal.ZopeFindAndApply(self.context, search_sub=True, apply_func=self.get_portlets) + self.get_root_portlets() return self.results - def get_portlets(self,obj, path): + def get_portlets(self, obj, path): uid = IUUID(obj, None) if not uid: return + self._get_portlets(obj, uid) + + def _get_portlets(self, obj, uid): portlets = export_local_portlets(obj) blacklist = export_portlets_blacklist(obj) portlets = self.local_portlets_hook(portlets) @@ -659,6 +663,11 @@ def get_portlets(self,obj, path): obj_results["uuid"] = uid self.results.append(obj_results) return + + def get_root_portlets(self): + site = api.portal.get() + self._get_portlets(site, PORTAL_PLACEHOLDER) + return def local_portlets_hook(self, portlets): return portlets diff --git a/src/collective/exportimport/import_other.py b/src/collective/exportimport/import_other.py index bea42f5f..043337a5 100644 --- a/src/collective/exportimport/import_other.py +++ b/src/collective/exportimport/import_other.py @@ -700,7 +700,11 @@ def import_portlets(self, data): for item in data: obj = api.content.get(UID=item["uuid"]) if not obj: - continue + if item["uuid"] == PORTAL_PLACEHOLDER: + obj = api.portal.get() + else: + logger.info("Could not find object to set portlet on UUID: {}".format(item["uuid"])) + continue registered_portlets = register_portlets(obj, item) results += registered_portlets return results