diff --git a/.github/workflows/meta.yml b/.github/workflows/meta.yml index df9c753..a25ff2f 100644 --- a/.github/workflows/meta.yml +++ b/.github/workflows/meta.yml @@ -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: diff --git a/.meta.toml b/.meta.toml index daa9e65..fa3d876 100644 --- a/.meta.toml +++ b/.meta.toml @@ -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" @@ -24,3 +24,11 @@ test_matrix = {"6.2" = ["*"]} extra_lines = """ coverage.xml """ + +[github] +jobs = [ + "qa", + "coverage", + "dependencies", + "release_ready", +] diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4147f59..2ba696d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/dependabot.yml b/dependabot.yml deleted file mode 100644 index bbd3ab0..0000000 --- a/dependabot.yml +++ /dev/null @@ -1,11 +0,0 @@ -# Generated from: -# https://github.com/plone/meta/tree/main/config/default -# See the inline comments on how to expand/tweak this configuration file -version: 2 -updates: - - - package-ecosystem: "github-actions" - directory: "/" - schedule: - # Check for updates to GitHub Actions every week - interval: "weekly" diff --git a/news/86.feature b/news/86.feature new file mode 100644 index 0000000..7cb673f --- /dev/null +++ b/news/86.feature @@ -0,0 +1 @@ +Make it easy to customize which content gets exported @gforcada diff --git a/src/plone/exportimport/exporters/configure.zcml b/src/plone/exportimport/exporters/configure.zcml index ba9c8bb..05fa2d3 100644 --- a/src/plone/exportimport/exporters/configure.zcml +++ b/src/plone/exportimport/exporters/configure.zcml @@ -15,6 +15,11 @@ for="plone.base.interfaces.siteroot.IPloneSiteRoot" name="plone.exporter.content" /> + 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" @@ -39,7 +36,7 @@ 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 @@ -47,6 +44,20 @@ def all_objects(self) -> Generator: 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) @@ -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() diff --git a/src/plone/exportimport/interfaces.py b/src/plone/exportimport/interfaces.py index fd2b3fb..a98ec34 100644 --- a/src/plone/exportimport/interfaces.py +++ b/src/plone/exportimport/interfaces.py @@ -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."""