Skip to content

Custom exporter logic - #2101

Open
gforcada wants to merge 1 commit into
6.0from
custom-export
Open

Custom exporter logic#2101
gforcada wants to merge 1 commit into
6.0from
custom-export

Conversation

@gforcada

@gforcada gforcada commented Aug 21, 2026

Copy link
Copy Markdown
Member

Description

This is part of plone/plone.exportimport#86

Where an easy way to customize the default content exporter is added.

@stevepiercy

Copy link
Copy Markdown
Member

@gforcada would you please request a review from whoever can provide a technical review? I've already requested two folks, based on the linked PR and the related training author.

@gforcada

Copy link
Copy Markdown
Member Author

@stevepiercy thanks for doing that, I will try to remember next time. I will add another one, just to have higher chances of one actually reviewing it

@gforcada
gforcada requested a review from ericof August 21, 2026 11:07
@stevepiercy

Copy link
Copy Markdown
Member

I'll do an editorial review, after the technical parts are verified. Thanks for your collaboration.

@davisagli davisagli left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks accurate for the proposed implementation in plone/plone.exportimport#86, but I also asked a question there to confirm whether @gforcada has confirmed this does what he needs.


There are other scenarios where a custom data export makes sense:

- sensible content should not be exported

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- sensible content should not be exported
- sensitive content should not be exported

"sensible" means "it makes sense"
"sensitive" means "delicate" or "secret"

self.obj = obj
self.errors = None

def get_objects(self, query, errors) -> Generator:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Show the import of Generator


For that, you can _override_ the `plone.exportimport.interfaces.IObjectsExporter` adapter.

On `overrides.zcml` add:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
On `overrides.zcml` add:
In {file}`overrides.zcml` add:

/>
```

On `my.package.adapters.py` add:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
On `my.package.adapters.py` add:
In {file}`my.package.adapters.py` add:

With this, the default `plone-exporter` will no longer export **all content**.

```{warning}
As soon as you override the export be aware that other parts of the export might not work.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was more worried about whether the import works. For example if 10% of content is exported by the content step but 100% of relations are exported by the relations step, then the import might fail when there is a relation that refers to one of the content items that was not included. Can you at least do a sanity check that this works in your case?

# custom logic to select which specific content gets exported
```

With this, the default `plone-exporter` will no longer export **all content**.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a bit of a limitation. Maybe you want all of the content sometimes, and different subsets at other times. This makes me wonder whether we should have named IObjectsExporter adapters, and make it possible to specify which one to use in the CLI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

3 participants