Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ jobs:
uses: plone/meta/.github/workflows/dependencies.yml@2.x
release_ready:
uses: plone/meta/.github/workflows/release_ready.yml@2.x
circular:
uses: plone/meta/.github/workflows/circular.yml@2.x

##
# To modify the list of default jobs being created add in .meta.toml:
Expand Down
10 changes: 9 additions & 1 deletion .meta.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# See the inline comments on how to expand/tweak this configuration file
[meta]
template = "default"
commit-id = "2.8.1.dev0"
commit-id = "2.10.0"

[pyproject]
codespell_skip = "*.min.js"
Expand All @@ -24,3 +24,11 @@ test_matrix = {"6.2" = ["*"]}
extra_lines = """
coverage.xml
"""

[github]
jobs = [
"qa",
"coverage",
"dependencies",
"release_ready",
]
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repos:
hooks:
- id: isort
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 26.3.1
rev: 26.5.1
hooks:
- id: black
- repo: https://github.com/collective/zpretty
Expand Down
11 changes: 0 additions & 11 deletions dependabot.yml

This file was deleted.

1 change: 1 addition & 0 deletions news/86.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make it easy to customize which content gets exported @gforcada
5 changes: 5 additions & 0 deletions src/plone/exportimport/exporters/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
for="plone.base.interfaces.siteroot.IPloneSiteRoot"
name="plone.exporter.content"
/>
<adapter
factory=".content.ObjectsExporter"
provides="plone.exportimport.interfaces.IObjectsExporter"
for="plone.base.interfaces.siteroot.IPloneSiteRoot"
/>
<adapter
factory=".principals.PrincipalsExporter"
provides="plone.exportimport.interfaces.INamedExporter"
Expand Down
32 changes: 21 additions & 11 deletions src/plone/exportimport/exporters/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,19 @@
from plone.exportimport.interfaces import IExportImportRequestMarker
from plone.exportimport.utils import content as content_utils
from plone.exportimport.utils import request_provides
from zope.component import getAdapter
from zope.interface import implementer

import argparse


@implementer(interfaces.INamedExporter)
class ContentExporter(BaseExporter):
name: str = "content"
query: dict = None
filename_fmt: str = settings.EXPORT_CONTENT_FILEPATH
metadata: types.ExportImportMetadata = None
default_site_language: str = "en"
class ObjectsExporter:

def all_objects(self) -> Generator:
def __init__(self, obj) -> None:
self.obj = obj

def get_objects(self, query, errors) -> Generator:
"""Return all objects to be serialized."""
query = self.query
catalog = api.portal.get_tool("portal_catalog")
if "object_provides" not in query:
query["object_provides"] = "plone.dexterity.interfaces.IDexterityContent"
Expand All @@ -39,14 +36,28 @@ def all_objects(self) -> Generator:
except Exception:
brain_path = brain.getPath()
msg = f"Error getting object {brain_path} from brain"
self.errors.append({"path": brain_path, "message": msg})
errors.append({"path": brain_path, "message": msg})
logger.exception(msg, exc_info=True)
else:
yield obj

if not index % 100:
logger.info(f"Content Exporter: Handled {index} items...")


@implementer(interfaces.INamedExporter)
class ContentExporter(BaseExporter):
name: str = "content"
query: dict = None
filename_fmt: str = settings.EXPORT_CONTENT_FILEPATH
metadata: types.ExportImportMetadata = None
default_site_language: str = "en"

def all_objects(self) -> Generator:
"""Return all objects to be serialized."""
adapter = getAdapter(self.site, interfaces.IObjectsExporter)
yield from adapter.get_objects(self.query, self.errors)

def serialize(self, obj: DexterityContent) -> dict:
"""Serialize object."""
obj_uid = content_utils.get_uid(obj)
Expand Down Expand Up @@ -152,7 +163,6 @@ def export_data(
) -> list[Path]:
# Content in a subpath of base_path
base_path = base_path / self.name
query = query if query else {}
site = self.site
self.query = query if query else {"path": content_utils.get_obj_path(site)}
metadata = types.ExportImportMetadata()
Expand Down
4 changes: 4 additions & 0 deletions src/plone/exportimport/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ class INamedExporter(Interface):

class INamedImporter(Interface):
"""Component to import content from a Plone Site."""


class IObjectsExporter(Interface):
"""Component to decide which objects are exported from a Plone Site."""