Skip to content

Commit

Permalink
Do not register IInvolvedID adapter for ISiteRoot on Plone6 because n…
Browse files Browse the repository at this point in the history
…ow it is a content with UID
  • Loading branch information
cekk committed Oct 14, 2024
1 parent e4b4548 commit f37ba67
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ include
local
share
.vscode
.python-version

3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Changelog
1.2.3 (unreleased)
------------------

- Nothing changed yet.
- Do not register IInvolvedID adapter for ISiteRoot on Plone6 because now it is a content with UID.
[cekk]


1.2.2 (2024-02-29)
Expand Down
2 changes: 2 additions & 0 deletions base.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,5 @@ mode = 755
recipe = zc.recipe.egg
eggs = createcoverage

[versions]
setuptools =
1 change: 0 additions & 1 deletion plone-6.0.x.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ extends =
update-versions-file = test_plone60.cfg

[versions]
importlib-metadata = 4.4.0
6 changes: 5 additions & 1 deletion src/collective/purgebyid/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@
<adapter factory=".purge.UuidPurgePath" name="collective.purgebyid.uuid" />

<adapter factory=".adapter.content_adapter" />

<configure zcml:condition="not-have plone-60">
<adapter factory=".adapter.site_root_adapter" />
</configure>

<adapter factory=".adapter.resource_directory_adapter" />
<adapter factory=".adapter.site_root_adapter" />
<adapter zcml:condition="installed Products.ResourceRegistry" factory=".adapter.resource_registry_adapter" />

<!-- Mutator: plone.transformchain order 11000 -->
Expand Down
22 changes: 22 additions & 0 deletions src/collective/purgebyid/tests/test_purge.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from importlib import import_module
from collective.purgebyid.api import mark_involved
from collective.purgebyid.api import mark_involved_objects
from collective.purgebyid.interfaces import IInvolvedID
Expand All @@ -24,6 +25,10 @@
import transaction
import unittest

HAS_PLONE_6 = getattr(
import_module("Products.CMFPlone.factory"), "PLONE60MARKER", False
)


class MarkerInterface(Interface):
"""A marker interface"""
Expand Down Expand Up @@ -53,6 +58,16 @@ def test_header_published(self):
ids = browser.headers["X-Ids-Involved"].strip("#").split("#")
self.assertIn(IUUID(document), ids)

@unittest.skipUnless(HAS_PLONE_6, "On Plone6 site root is a content")
def test_header_published_on_site_root(self):
"""Test if the headers are published on site root too."""
setRoles(self.portal, TEST_USER_ID, ("Manager",))
browser = Browser(self.app)
browser.open(self.portal.absolute_url())
self.assertTrue("X-Ids-Involved" in browser.headers)
ids = browser.headers["X-Ids-Involved"].strip("#").split("#")
self.assertIn(IUUID(self.portal), ids)

def test_involved_adapter(self):
"""Test if the headers are published."""
setRoles(self.portal, TEST_USER_ID, ("Manager",))
Expand Down Expand Up @@ -86,11 +101,18 @@ def document_adapter(obj):
provided=IInvolvedID,
)

@unittest.skipIf(HAS_PLONE_6, "On Plone6 site root is a content")
def test_resource(self):
browser = Browser(self.app)
browser.open(self.portal.absolute_url() + "/favicon.ico")
self.assertFalse("X-Ids-Involved" in browser.headers)

@unittest.skipUnless(HAS_PLONE_6, "On Plone6 site root is a content")
def test_resource_p6(self):
browser = Browser(self.app)
browser.open(self.portal.absolute_url() + "/favicon.ico")
self.assertTrue("X-Ids-Involved" in browser.headers)

def test_purge_content(self):
document = api.content.create(
title="Document", id="document", type="Document", container=self.portal
Expand Down

0 comments on commit f37ba67

Please sign in to comment.