Skip to content
Browse files

An ObjectManger may have a registry even if it doesn't provide the

ISite interface.
  • Loading branch information...
1 parent ff63370 commit 350769e73a11db16790b2f679eaa3239eade9ef6 @rpatterson committed Dec 5, 2011
Showing with 18 additions and 12 deletions.
  1. +18 −9 Products/CMFEditions/StandardModifiers.py
  2. +0 −3 Products/CMFEditions/tests/test_IntegrationTests.py
View
27 Products/CMFEditions/StandardModifiers.py
@@ -34,8 +34,8 @@
from Acquisition import aq_base
from zope.interface import implements, Interface
-from zope.component import globalregistry
-from zope.location.interfaces import ISite
+from zope.component.interfaces import ComponentLookupError
+from zope.location.interfaces import IPossibleSite
from ZODB.blob import Blob
from OFS.ObjectManager import ObjectManager
from Products.BTreeFolder2.BTreeFolder2 import BTreeFolder2Base
@@ -867,13 +867,22 @@ class SkipRegistryBasesPointers:
implements(ICloneModifier, ISaveRetrieveModifier)
+ def getSiteManager(self, obj):
+ if not IPossibleSite.providedBy(obj):
+ return
+ try:
+ registry = obj.getSiteManager()
+ except ComponentLookupError:
+ return
+ return registry
+
def getOnCloneModifiers(self, obj):
"""Removes component registry bases pointers and stores a marker
"""
- if not ISite.providedBy(obj):
- return None
+ registry = self.getSiteManager(obj)
+ if registry is None:
+ return
- registry = obj.getSiteManager()
component_bases = dict(
registry=dict((id(aq_base(base)), aq_base(base))
for base in registry.__bases__),
@@ -897,15 +906,15 @@ def persistent_load(obj):
def beforeSaveModifier(self, obj, clone):
"""Don't save the bases."""
- if ISite.providedBy(clone):
- sm = clone.getSiteManager()
+ sm = self.getSiteManager(clone)
+ if sm is not None:
sm.__bases__ = ()
return {}, [], []
def afterRetrieveModifier(self, obj, repo_clone, preserve=()):
"""Does nothing, the pickler does the work"""
- if ISite.providedBy(repo_clone) and obj is not None:
- sm = repo_clone.getSiteManager()
+ sm = self.getSiteManager(repo_clone)
+ if sm is not None and obj is not None:
obj_sm = obj.getSiteManager()
sm.__bases__ = obj_sm.__bases__
return [], [], {}
View
3 Products/CMFEditions/tests/test_IntegrationTests.py
@@ -38,8 +38,6 @@
import ZODB.interfaces
from ZODB import broken
from Acquisition import aq_base
-from Products.Five.component import enableSite
-from Products.Five.component.interfaces import IObjectManagerSite
class TestIntegration(PloneTestCase.PloneTestCase):
@@ -1139,7 +1137,6 @@ def test23_RegistryBasesNotVersionedOrRestored(self):
fol.setTitle("v1")
# Make it a component registry with bases
base = aq_base(self.portal.getSiteManager())
- enableSite(fol, iface=IObjectManagerSite)
components = PersistentComponents()
components.__bases__ = (base,)
fol.setSiteManager(components)

0 comments on commit 350769e

Please sign in to comment.
Something went wrong with that request. Please try again.