Skip to content

Commit

Permalink
Merge pull request #219 from collective/root_portlets
Browse files Browse the repository at this point in the history
  • Loading branch information
pbauer authored Sep 29, 2023
2 parents 5d5a40a + 26bb013 commit a12fa66
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Changelog

- Better support for portal import which avoids parsing JSON twice.
[gotcha]
- Migrate portlets on site root.
[ThibautBorn]

1.9 (2023-05-18)
----------------
Expand Down
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 a12fa66

Please sign in to comment.