Repository navigation
Do not fail exporting content whose language is null - #105
Conversation
fix_language read the serialized language with item.get("language", {}). The
default only applies when the key is absent, and content without a language
serializes to "language": null, so the key is there holding None and the
following .get("token", ...) raised AttributeError: 'NoneType' object has no
attribute 'get'. Exporting a site with content in the language independent
folder, such as classic.demo.plone.org, stopped there.
A language of None is now treated the same as a missing language: the item gets
the default-language placeholder, and deciding on a real language is left to
the import, where the parent is known.
Two tests: a case in the existing test_fix_language table, and an export of a
real content item whose language has been set to None, asserting the exported
data.json carries the placeholder.
Measured with pytest and the Plone 6.2-dev constraints: tests/utils and
tests/exporters went from 176 to 178 passing. The whole suite went from 227 to
229 passing with the same 15 failures and 8 errors before and after; those are
pre-existing and come from test ordering, since tests/utils on its own is 101
passing on an unmodified checkout. Reverting only export_helpers.py and keeping
the tests fails exactly the two new cases.
Fixes plone#95
|
@kunalKumar-13 thanks for creating this Pull Request and helping to improve Plone! TL;DR: Finish pushing changes, pass all other checks, then paste a comment: 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! |
|
@jenkins-plone-org please run jobs |
1 similar comment
|
@jenkins-plone-org please run jobs |
|
The Jenkins jobs here have been @jenkins-plone-org please run jobs |
|
Jenkins has reported since my nudge, and some jobs are red. They are the acceptance layer timing out on browser startup, not this change — the logs are full of It is not specific to this PR: the same signature appears on the other branches I nudged today, and Owning the part that is mine: these jobs had been |
|
The red Jenkins jobs are infrastructure, not this PR. Build That node also turns out to be missing a Chromium revision the 6.0 line needs, which I |
|
@jenkins-plone-org please run jobs |
Fixes #95.
fix_languagereads the serialized language withitem.get("language", {}). Thedefault only applies when the key is absent, and content without a language
serializes to
"language": null— so the key is there holdingNone, and thefollowing
.get("token", ...)raisesAttributeError: 'NoneType' object has no attribute 'get'. Exporting a site withcontent in the language independent folder, like
classic.demo.plone.org, stopsthere.
A language of
Noneis now treated the same as a missing language: the item getsPLACEHOLDERS_LANGUAGE, and deciding on a real language is left to the import,where the parent is known — which is what you asked for in the issue.
Noneismapped explicitly rather than with
or {}so that""keeps taking the stringbranch it takes today.
Tests
{"language": None}row in the existingtest_fix_languagetable;languagehas been set toNone,asserting the written
data.jsoncarries the placeholder — this is the pathfrom your traceback.
tests/utils+tests/exportersgo from 176 to 178 passing. The whole suitegoes from 227 to 229 passing with the same 15 failures and 8 errors before and
after; those are pre-existing and come from test ordering —
tests/utilson itsown is 101 passing on an unmodified checkout. Reverting only
export_helpers.pyand keeping the tests fails exactly the two new cases.