diff --git a/src/plone/exportimport/deserializers/blob.py b/src/plone/exportimport/deserializers/blob.py index d7ec817..94e84c2 100644 --- a/src/plone/exportimport/deserializers/blob.py +++ b/src/plone/exportimport/deserializers/blob.py @@ -1,7 +1,7 @@ from pathlib import Path from plone.dexterity.interfaces import IDexterityContent from plone.exportimport import settings -from plone.exportimport.interfaces import IExportImportBlobsMarker +from plone.exportimport.interfaces import IExportImportRequestMarker from plone.exportimport.utils import path as path_utils from plone.namedfile.interfaces import INamedField from plone.restapi.deserializer.dxfields import DefaultFieldDeserializer @@ -24,7 +24,7 @@ def load_blob(path: str) -> bytes: return codecs.decode(data, "base64") -@adapter(INamedField, IDexterityContent, IExportImportBlobsMarker) +@adapter(INamedField, IDexterityContent, IExportImportRequestMarker) @implementer(IFieldDeserializer) class ExportImportNamedFieldDeserializer(DefaultFieldDeserializer): def __call__(self, value): diff --git a/src/plone/exportimport/deserializers/blocks.py b/src/plone/exportimport/deserializers/blocks.py new file mode 100644 index 0000000..d7c1888 --- /dev/null +++ b/src/plone/exportimport/deserializers/blocks.py @@ -0,0 +1,15 @@ +from plone.exportimport.interfaces import IExportImportRequestMarker +from plone.restapi.behaviors import IBlocks +from plone.restapi.deserializer.dxfields import DefaultFieldDeserializer +from plone.restapi.interfaces import IFieldDeserializer +from plone.schema import IJSONField +from zope.component import adapter +from zope.interface import implementer + + +@implementer(IFieldDeserializer) +@adapter(IJSONField, IBlocks, IExportImportRequestMarker) +class ExportImportBlocksDeserializer(DefaultFieldDeserializer): + """We skip the subscribers that deserialize the blocks from the frontend. + We only need the raw data. + """ diff --git a/src/plone/exportimport/deserializers/configure.zcml b/src/plone/exportimport/deserializers/configure.zcml index c8b5b4b..699b793 100644 --- a/src/plone/exportimport/deserializers/configure.zcml +++ b/src/plone/exportimport/deserializers/configure.zcml @@ -1,3 +1,4 @@ + diff --git a/src/plone/exportimport/exporters/content.py b/src/plone/exportimport/exporters/content.py index df8478d..51c31ba 100644 --- a/src/plone/exportimport/exporters/content.py +++ b/src/plone/exportimport/exporters/content.py @@ -7,7 +7,7 @@ from plone.exportimport import logger from plone.exportimport import settings from plone.exportimport import types -from plone.exportimport.interfaces import IExportImportBlobsMarker +from plone.exportimport.interfaces import IExportImportRequestMarker from plone.exportimport.utils import content as content_utils from plone.exportimport.utils import request_provides from typing import Callable @@ -130,7 +130,7 @@ def dump_metadata(self) -> Path: def dump(self) -> List[Path]: """Serialize contents and dump them to disk.""" paths = [] - with request_provides(self.request, IExportImportBlobsMarker): + with request_provides(self.request, IExportImportRequestMarker): for obj in self.all_objects(): path = self.dump_one(obj) if path: diff --git a/src/plone/exportimport/importers/content.py b/src/plone/exportimport/importers/content.py index 7dd8af6..f6d94a6 100644 --- a/src/plone/exportimport/importers/content.py +++ b/src/plone/exportimport/importers/content.py @@ -4,7 +4,7 @@ from plone.exportimport import logger from plone.exportimport import settings from plone.exportimport import types -from plone.exportimport.interfaces import IExportImportBlobsMarker +from plone.exportimport.interfaces import IExportImportRequestMarker from plone.exportimport.utils import content as content_utils from plone.exportimport.utils import request_provides from typing import Callable @@ -93,7 +93,7 @@ def construct(self, item: dict) -> DexterityContent: def do_import(self) -> str: objs = [] modified = set() - with request_provides(self.request, IExportImportBlobsMarker): + with request_provides(self.request, IExportImportRequestMarker): for index, item in enumerate(self.all_objects(), start=1): obj = self.construct(item) obj_path = "/".join(obj.getPhysicalPath()) diff --git a/src/plone/exportimport/interfaces.py b/src/plone/exportimport/interfaces.py index 3c0e518..0f3c732 100644 --- a/src/plone/exportimport/interfaces.py +++ b/src/plone/exportimport/interfaces.py @@ -3,7 +3,7 @@ from zope.interface import Interface -class IExportImportBlobsMarker(Interface): +class IExportImportRequestMarker(Interface): """A marker interface to override default serializers.""" diff --git a/src/plone/exportimport/serializers/blob.py b/src/plone/exportimport/serializers/blob.py index 4b1179a..6202fec 100644 --- a/src/plone/exportimport/serializers/blob.py +++ b/src/plone/exportimport/serializers/blob.py @@ -4,7 +4,7 @@ from plone.exportimport import logger from plone.exportimport import settings from plone.exportimport import types -from plone.exportimport.interfaces import IExportImportBlobsMarker +from plone.exportimport.interfaces import IExportImportRequestMarker from plone.exportimport.utils import content as content_utils from plone.exportimport.utils import path as path_utils from plone.namedfile.interfaces import INamedBlobFileField @@ -19,7 +19,7 @@ from zope.interface import implementer -@adapter(INamedBlobFileField, IDexterityContent, IExportImportBlobsMarker) +@adapter(INamedBlobFileField, IDexterityContent, IExportImportRequestMarker) @implementer(IFieldSerializer) class ExportImportFileFieldSerializer(DefaultFieldSerializer): def __call__(self): @@ -37,13 +37,13 @@ def __call__(self): return json_compatible(result) -@adapter(INamedFileField, IDexterityContent, IExportImportBlobsMarker) +@adapter(INamedFileField, IDexterityContent, IExportImportRequestMarker) @implementer(IFieldSerializer) class ExportImportSimpleFileFieldSerializer(ExportImportFileFieldSerializer): """Same as above but less specific field interface""" -@adapter(INamedBlobImageField, IDexterityContent, IExportImportBlobsMarker) +@adapter(INamedBlobImageField, IDexterityContent, IExportImportRequestMarker) @implementer(IFieldSerializer) class ExportImportImageFieldSerializer(DefaultFieldSerializer): def __call__(self): @@ -65,7 +65,7 @@ def __call__(self): return json_compatible(result) -@adapter(INamedImageField, IDexterityContent, IExportImportBlobsMarker) +@adapter(INamedImageField, IDexterityContent, IExportImportRequestMarker) @implementer(IFieldSerializer) class ExportImportSimpleImageFieldSerializer(ExportImportImageFieldSerializer): """Same as above but less specific field interface""" diff --git a/src/plone/exportimport/serializers/blocks.py b/src/plone/exportimport/serializers/blocks.py new file mode 100644 index 0000000..7d37c48 --- /dev/null +++ b/src/plone/exportimport/serializers/blocks.py @@ -0,0 +1,15 @@ +from plone.exportimport.interfaces import IExportImportRequestMarker +from plone.restapi.behaviors import IBlocks +from plone.restapi.interfaces import IFieldSerializer +from plone.restapi.serializer.dxfields import DefaultFieldSerializer +from plone.schema import IJSONField +from zope.component import adapter +from zope.interface import implementer + + +@adapter(IJSONField, IBlocks, IExportImportRequestMarker) +@implementer(IFieldSerializer) +class ExportImportBlocksSerializer(DefaultFieldSerializer): + """We skip the subscribers that serialize the blocks for the frontend. + We only need the raw data. + """ diff --git a/src/plone/exportimport/serializers/configure.zcml b/src/plone/exportimport/serializers/configure.zcml index a3372e7..ede113e 100644 --- a/src/plone/exportimport/serializers/configure.zcml +++ b/src/plone/exportimport/serializers/configure.zcml @@ -3,5 +3,5 @@ - +