Skip to content

Add basic import/export REST API services#88

Merged
davisagli merged 5 commits into
mainfrom
restapi
Feb 5, 2026
Merged

Add basic import/export REST API services#88
davisagli merged 5 commits into
mainfrom
restapi

Conversation

@davisagli
Copy link
Copy Markdown
Member

Fixes #87

@davisagli davisagli requested a review from ericof January 27, 2026 01:38
@mister-roboto
Copy link
Copy Markdown

@davisagli thanks for creating this Pull Request and helping to improve Plone!

TL;DR: Finish pushing changes, pass all other checks, then paste a comment:

@jenkins-plone-org please run jobs

To ensure that these changes do not break other parts of Plone, the Plone test suite matrix needs to pass, but it takes 30-60 min. Other CI checks are usually much faster and the Plone Jenkins resources are limited, so when done pushing changes and all other checks pass either start all Jenkins PR jobs yourself, or simply add the comment above in this PR to start all the jobs automatically.

Happy hacking!

@davisagli
Copy link
Copy Markdown
Member Author

Note: needs more investigation to see why the 2nd export isn't the same if we export, then import, then export

Copy link
Copy Markdown
Member

@sneridagh sneridagh left a comment

Choose a reason for hiding this comment

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

LGTM. @ericof ?

@davisagli
Copy link
Copy Markdown
Member Author

@ericof The test failure is, at least in part, because the plone site is getting imported inside the existing plone site, instead of replacing it. Any ideas how we should handle this?

…rn the parent of a Plone Site during functional tests
@ericof
Copy link
Copy Markdown
Member

ericof commented Feb 3, 2026

@davisagli I would suggest accepting an option to filter what do you want to be exported (i.e.: Not exporting portlets, or translations)

Copy link
Copy Markdown
Member

@ericof ericof left a comment

Choose a reason for hiding this comment

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

I would like to have a way of selecting what is going to be exported, but other than that this is really good.

@davisagli
Copy link
Copy Markdown
Member Author

@ericof Can we merge it as is and then add more options as an improvement? We should make the new options consistent between the API and the CLI, and I don't want to tackle it today.

@ericof
Copy link
Copy Markdown
Member

ericof commented Feb 4, 2026

Go for it

Copy link
Copy Markdown
Member

@mauritsvanrees mauritsvanrees left a comment

Choose a reason for hiding this comment

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

Nice! I may want to use this to export and import content from one instance of a Ploneconf website to another.

I will try it soon.

Meanwhile the code looks good. There is one typo (missing search-replace) in the tests, see inline suggestion.

Comment thread tests/services/test_services.py Outdated
Copy link
Copy Markdown
Member

@mauritsvanrees mauritsvanrees left a comment

Choose a reason for hiding this comment

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

Seems to work fine when trying it locally on an almost bare Classic UI site.
Two more inline suggestions for the readme, to fix the curl commands.

Comment thread README.md Outdated
Comment thread README.md Outdated
Comment thread README.md Outdated
@mauritsvanrees
Copy link
Copy Markdown
Member

One comment in general. I remember from a long time ago that you could make a zexp to export content. Hey, it still works!
This would work fine, also through Apache/nginx or such, except that you could get a timeout if Zope did not start answering in time. But for larger sites the time it took to finish serving this file would dramatically/exponentially increase. Maybe the browser or an intermediate server would retry the request, or Zope would get a ReadConflictError and try again. I don't know. Saving it to a file on the server instead of downloading it was way faster in that case.

Of course the technology underlying the rest api is quite different. But if in real world usage you see that the export takes much longer than expected, then think back to this remark.

We don't need to do anything at this point, we will cross that bridge when we find it.

davisagli and others added 2 commits February 4, 2026 17:35
Co-authored-by: Maurits van Rees <maurits@vanrees.org>
Co-authored-by: Maurits van Rees <maurits@vanrees.org>
@davisagli
Copy link
Copy Markdown
Member Author

@mauritsvanrees Thanks for the review! Yeah, I know this will not work well for exporting large sites. But we have the CLI script as well. The goal here is to give another option that might be more convenient for small exports.

@davisagli davisagli merged commit 2f0abe1 into main Feb 5, 2026
15 of 18 checks passed
@davisagli davisagli deleted the restapi branch February 5, 2026 01:56
@sneridagh
Copy link
Copy Markdown
Member

@davisagli Reviewing the docs today, I realised that probably this is the first core package where we create a RESTAPI endpoint outside plone.restapi. Not that I think is bad, but is worth notice it, specially for the sake of unify documentation for the RESTAPI.

@davisagli
Copy link
Copy Markdown
Member Author

@sneridagh This is a good point for us to discuss. I like keeping the service implementation alongside the other code it's closely related to, but we should try to have the documentation unified for everything that's in core (or core add-ons). It's too much work to maintain docs here and pull them into plone.restapi's docs automatically. I can work on adding the docs in plone.restapi.

@sneridagh
Copy link
Copy Markdown
Member

@davisagli Don't get me wrong, I agree that the implementation has to live where the code is. We have to make sure that the docs remain unified, maybe with the proper mention where the code is, if it makes sense.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add REST API services for exporting and importing (as a zip file)

5 participants