Skip to content

Commit

Permalink
Merge pull request #213 from collective/fix_useless_dumps
Browse files Browse the repository at this point in the history
  • Loading branch information
pbauer authored Sep 29, 2023
2 parents e9505b5 + 0821e7c commit 5d5a40a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Changelog
- Don't re-use `mapping` variable when migrating portlet data.
[witsch]

- Better support for portal import which avoids parsing JSON twice.
[gotcha]

1.9 (2023-05-18)
----------------
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
if sys.version_info[0] < 3:
install_requires.append("beautifulsoup4 < 4.10")
install_requires.append("plone.restapi < 8.0.0")
# There is a py2-imcompatibility in plone.rest 3.0.1
install_requires.append("plone.rest < 3.0.1")
# plone.restapi depends on plone.schema, which depends on jsonschema,
# which has a Py3-only release since September 2021.
install_requires.append("jsonschema < 4")
Expand Down
10 changes: 8 additions & 2 deletions src/collective/exportimport/import_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,15 @@ def handle_new_object(self, item, index, new):

# import using plone.restapi deserializers
deserializer = getMultiAdapter((new, self.request), IDeserializeFromJson)
self.request["BODY"] = json.dumps(item)
try:
new = deserializer(validate_all=False)
try:
new = deserializer(validate_all=False, data=item)
except TypeError as error:
if 'unexpected keyword argument' in str(error):
self.request["BODY"] = json.dumps(item)
new = deserializer(validate_all=False)
else:
raise error
except Exception:
logger.warning("Cannot deserialize %s %s", item["@type"], item["@id"], exc_info=True)
raise
Expand Down

0 comments on commit 5d5a40a

Please sign in to comment.