From 44dc04476601656c71e8d890a153a385fdcb5b8b Mon Sep 17 00:00:00 2001 From: Wolfgang Schnerring Date: Mon, 26 Feb 2024 16:32:49 +0100 Subject: [PATCH 1/2] ZO-4801: Add test that demonstrates the error --- core/docs/changelog/ZO-4801.change | 1 + core/src/zeit/cms/content/tests/test_reference.py | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 core/docs/changelog/ZO-4801.change diff --git a/core/docs/changelog/ZO-4801.change b/core/docs/changelog/ZO-4801.change new file mode 100644 index 0000000000..ae07670eb6 --- /dev/null +++ b/core/docs/changelog/ZO-4801.change @@ -0,0 +1 @@ +ZO-4801: Fix saving audio reference on article diff --git a/core/src/zeit/cms/content/tests/test_reference.py b/core/src/zeit/cms/content/tests/test_reference.py index 273fba95f2..1a10455f55 100644 --- a/core/src/zeit/cms/content/tests/test_reference.py +++ b/core/src/zeit/cms/content/tests/test_reference.py @@ -223,6 +223,19 @@ def test_works_with_security(self): content.references = content.references.create(target) self.assertEqual('http://xml.zeit.de/target', content.references.target.uniqueId) + def test_works_with_security_on_adapter(self): + target = zope.security.proxy.ProxyFactory(self.repository['target']) + with checked_out(self.repository['content']) as co: + content = zope.security.proxy.ProxyFactory(co) + # The IRelatedContent adapter is registered with trusted=true, + # but it's unclear whether this is the general contract for these: + # ReferenceProperty already does use removeSecurityProxy, and there + # also currently are some adapters that do not use trusted (e.g. + # z.c.audio). So we probably ought to support this case. + related = zeit.cms.related.related.RelatedContent(content) + related.related = (target,) + self.assertEqual('http://xml.zeit.de/target', related.related[0].uniqueId) + class MultiResourceTest(ReferenceFixture, zeit.cms.testing.ZeitCmsTestCase): def setUp(self): From bde155acd31aa9c292585a2b848a8dbbbe77db12 Mon Sep 17 00:00:00 2001 From: Wolfgang Schnerring Date: Mon, 26 Feb 2024 16:33:04 +0100 Subject: [PATCH 2/2] ZO-4801, ZO-4627: Fix copy&paste mistake in 7cc4d95 --- core/src/zeit/cms/content/reference.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/zeit/cms/content/reference.py b/core/src/zeit/cms/content/reference.py index 777940a5c2..1c34395357 100644 --- a/core/src/zeit/cms/content/reference.py +++ b/core/src/zeit/cms/content/reference.py @@ -124,7 +124,7 @@ def __set__(self, instance, value): else: for node in self._reference_nodes(instance): node.getparent().remove(node) - parent, name = create_parent_nodes(self.path, instance.xml) + parent, name = create_parent_nodes(self.path, xml) for node in value: node.tag = name parent.append(node)