Skip to content

Commit 7b7f8bc

Browse files
authored
Remove unused utility method parent_site. (#69)
This could break other people's code, but this method is not used anywhere in collective.lineage.
1 parent d531a03 commit 7b7f8bc

3 files changed

Lines changed: 11 additions & 39 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Remove unused utility method parent_site.
2+
3+
This could break other people's code, but this method is not used anywhere in
4+
collective.lineage.
5+
[thet]

src/collective/lineage/tests/test_utils.py

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
1-
from .. import testing
21
from collective.lineage import utils
2+
from collective.lineage.testing import LineageTestCase
33
from plone.browserlayer import utils as layer_utils
4-
from zope import component
5-
from zope import interface
6-
from zope.site.hooks import site as site_hook
7-
8-
import unittest
4+
from zope.component import getSiteManager
5+
from zope.interface import Interface
96

107
PROJECTNAME = "collective.lineage"
118

129

13-
class IChildSiteLayer(interface.Interface):
10+
class IChildSiteLayer(Interface):
1411
"""
1512
An example browser layer for a child site.
1613
"""
1714

1815

19-
class UtilsTestCase(testing.LineageTestCase):
16+
class UtilsTestCase(LineageTestCase):
2017
"""
2118
Test the Lineage utility functions.
2219
"""
@@ -44,7 +41,7 @@ def test_childsite_browserlayer(self):
4441
layer_utils.register_layer(
4542
IChildSiteLayer,
4643
"collective.lineage.childsite.layer",
47-
site_manager=component.getSiteManager(self.childsite),
44+
site_manager=getSiteManager(self.childsite),
4845
)
4946

5047
self.assertFalse(
@@ -56,14 +53,3 @@ def test_childsite_browserlayer(self):
5653
IChildSiteLayer.providedBy(self.portal.REQUEST),
5754
"Child site browser layer not applied to the request",
5855
)
59-
60-
def test_parent_site_on_siteroot(self):
61-
site = utils.parent_site()
62-
self.assertEqual(site, self.portal)
63-
64-
@unittest.skip("Currently fails, due to `_find_site` always going for aq_parent.")
65-
def test_parent_site_on_childsite(self):
66-
utils.enable_childsite(self.childsite)
67-
with site_hook(self.childsite):
68-
site = utils.parent_site()
69-
self.assertEqual(site, self.childsite)

src/collective/lineage/utils.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
from Acquisition import aq_parent
21
from collective.lineage.events import ChildSiteCreatedEvent
32
from collective.lineage.events import ChildSiteRemovedEvent
43
from collective.lineage.events import ChildSiteWillBeCreatedEvent
54
from collective.lineage.events import ChildSiteWillBeRemovedEvent
65
from collective.lineage.interfaces import IChildSite
76
from five.localsitemanager import make_objectmanager_site
8-
from plone.base.interfaces import IPloneSiteRoot
97
from Products.Five.component import disableSite
10-
from zope.component.hooks import getSite
118
from zope.component.interfaces import ISite
129
from zope.event import notify
1310
from zope.interface import alsoProvides
@@ -39,19 +36,3 @@ def disable_childsite(context):
3936

4037
context.reindexObject(idxs=("object_provides"))
4138
notify(ChildSiteRemovedEvent(context))
42-
43-
44-
def parent_site():
45-
def _find_site(ctx):
46-
# First, stop at IPloneSiteRoot
47-
if IPloneSiteRoot.providedBy(ctx):
48-
return ctx
49-
# Then walk up
50-
ctx = aq_parent(ctx)
51-
if IChildSite.providedBy(ctx):
52-
return ctx
53-
return _find_site(ctx)
54-
55-
# Start at current site
56-
site = _find_site(getSite())
57-
return site

0 commit comments

Comments
 (0)