Skip to content

Commit

Permalink
Merge pull request #635 from ZeitOnline/ZO-4801
Browse files Browse the repository at this point in the history
ZO-4801: Fix saving audio reference on article
  • Loading branch information
stollero authored Feb 27, 2024
2 parents 07b97db + bde155a commit 5a0570c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions core/docs/changelog/ZO-4801.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ZO-4801: Fix saving audio reference on article
2 changes: 1 addition & 1 deletion core/src/zeit/cms/content/reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 13 additions & 0 deletions core/src/zeit/cms/content/tests/test_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 5a0570c

Please sign in to comment.