Skip to content

Give users the option to export portal data #270

@ThibautBorn

Description

@ThibautBorn

Currently, portal-level settings (like portlets, local roles, and default pages) are always exported.

This causes problems when migrating only part of a site (e.g. a folder) into another site that already contains data. Since these settings are included by default, they also get imported into the target site, resulting in unwanted local roles or portlets being added.

We do still need the option to migrate these settings when transferring a complete site into an empty instance.

I initially tried handling this through hooks, but this seems more of a patch than a real solution.

class CustomExportPortlets(ExportPortlets):
    # wanted to use the portlets hook to skip root portlets, but the uuid is not availble here.
    # 
    # def local_portlets_hook(self, item):
    #     if item.get('uuid') == PORTAL_PLACEHOLDER:
    #         return
    #     return item

    def all_portlets(self):
        self.results = []
        portal = api.portal.get()
        portal.ZopeFindAndApply(
            self.context, search_sub=True, apply_func=self.get_portlets
        )
        # don't migrate portlets on root anymore (#hackish workaround)
        #self.get_root_portlets()
        return self.results
    
class CustomExportLocalRoles(ExportLocalRoles):
    def item_hook(self, item):
        if item.get('uuid') == PORTAL_PLACEHOLDER:
            return
        return item

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions