Skip to content

Commit

Permalink
migrate portlets on site root
Browse files Browse the repository at this point in the history
context: migration only checked on uid, which left out the portal root
  • Loading branch information
ThibautBorn committed Sep 11, 2023
1 parent 5f035a6 commit 0736d4e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/collective/exportimport/export_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/collective/exportimport/import_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0736d4e

Please sign in to comment.