Fix blocks without image_scales and CLI export of protected fields - #111
Conversation
Grid block images exported without image_scales (missing or null), with an empty scales list, or without a scales key no longer break export and import. Closes #109
Under adopt_roles(["Manager"]), a permission check only succeeds when the permission is granted to Manager, bypassing the unrestricted system user set up by get_app. Fields whose read permission is granted only to other roles (e.g. Anonymous and Authenticated, as for the header settings behavior of sc.voltolighttheme on the Plone Site root) were silently dropped from exports. Both exporter_cli and importer_cli now run inside hooks.site(site) without overriding roles. get_site is annotated as returning PloneSite, since it exits when the site is not found. Tests: - New testing profile with a DummyContent type and a dummy_settings behavior on the Plone Site, with fields protected by custom read and write permissions. - CLI tests for exporter and importer, running on the functional layer. Closes #110
|
@ericof 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! |
pytest-plone 1.1.0 keeps test layers set up for the whole session. Importers commit the transaction by default (intermediate_commits), and the portal_multilingual fixtures committed through transaction.manager, so imported content, users and groups leaked into later integration tests. Previously each layer was rebuilt between tests, which hid the leak. - Add an autouse fixture disabling importer intermediate commits. - Stop committing in the portal_multilingual fixtures. - Declare plone.autoform, plone.behavior, plone.supermodel and Products.GenericSetup, imported by the plone.exportimport.testing package. - Drop the license classifier from setup.py.
|
@jenkins-plone-org please run jobs |
|
@gforcada It seems I also fixed the pytest issues |
|
@gforcada Could you approve it? :-) |
gforcada
left a comment
There was a problem hiding this comment.
Looks good 😄 there are a few parts, specially on tests that I skimmed over them, but otherwise looks fine 👍🏾
Summary
Two bug fixes found while exporting data for the new
plone.org.br.#109: blocks without
image_scales_fix_image_pathsinplone.exportimport.utils.content.blocksassumed every image entry in a grid block hadimage_scales. Export and import broke when the key was missing ornull, when a field had an empty scales list, or when the image data had noscaleskey. These entries are now left unchanged.#110: CLI export silently dropping protected fields
plone-exporterwrapped the export inapi.env.adopt_roles(["Manager"]). Underadopt_roles, a permission check succeeds only if the permission is granted to one of the adopted roles, and the user's own check is bypassed. The command line tools already run as the unrestricted system user (set up inget_app), so this override could only narrow permissions.Fields whose read permission is granted only to other roles were silently left out of the export. This happened with the header settings behavior of
sc.voltolighttheme, whose view permission is granted toAnonymousandAuthenticatedon the Plone Site root.Changes:
exporter_cliandimporter_clinow run insidehooks.site(site), withoutadopt_roles.get_siteis annotated as returningPloneSite, since it exits when the site is not found.Tests
_fix_image_pathsandparse_blocks.plone.exportimport.testing:testingprofile, loaded by the test layer:DummyContenttype with fields protected by custom read and write permissions;plone.exportimport.testing.dummy_settingsbehavior, enabled on the Plone Site;sc.voltolighttheme(view:Anonymous/Authenticated; edit:Manager/Site Administrator).tests/clitests that run the realexporter_cliandimporter_cli, patching only the Zope startup, on the functional layer (the importer commits). The exporter tests fail without the fix.Closes #109
Closes #110