[Checkins] SVN: Products.GenericSetup/branches/1.4/Products/GenericSetup/ Recognize acquisition-wrapped components as being of the right underlying

Tres Seaver tseaver at palladion.com
Wed Apr 22 13:57:27 EDT 2009


Log message for revision 99396:
  Recognize acquisition-wrapped components as being of the right underlying
  type when testing for replacement during import.  Patch from Erik Rose
  at PSU.
  

Changed:
  U   Products.GenericSetup/branches/1.4/Products/GenericSetup/CHANGES.txt
  U   Products.GenericSetup/branches/1.4/Products/GenericSetup/components.py
  U   Products.GenericSetup/branches/1.4/Products/GenericSetup/tests/test_components.py

-=-
Modified: Products.GenericSetup/branches/1.4/Products/GenericSetup/CHANGES.txt
===================================================================
--- Products.GenericSetup/branches/1.4/Products/GenericSetup/CHANGES.txt	2009-04-22 17:56:46 UTC (rev 99395)
+++ Products.GenericSetup/branches/1.4/Products/GenericSetup/CHANGES.txt	2009-04-22 17:57:27 UTC (rev 99396)
@@ -4,6 +4,10 @@
 GenericSetup 1.4.3 (unreleased)
 -------------------------------
 
+- Recognize acquisition-wrapped components as being of the right underlying
+  type when testing for replacement during import.  Patch from Erik Rose
+  at PSU.
+
 - Don't fail when a sub-item cannot be adapted after creation when
   importing a folder.  (https://bugs.launchpad.net/zope-cmf/+bug/300315)
 

Modified: Products.GenericSetup/branches/1.4/Products/GenericSetup/components.py
===================================================================
--- Products.GenericSetup/branches/1.4/Products/GenericSetup/components.py	2009-04-22 17:56:46 UTC (rev 99395)
+++ Products.GenericSetup/branches/1.4/Products/GenericSetup/components.py	2009-04-22 17:57:27 UTC (rev 99396)
@@ -171,7 +171,8 @@
                 assert len(current) <=1
 
                 new_utility = factory()
-                if current and type(current[0].component) == type(new_utility):
+                if (current and
+                    type(aq_base(current[0].component)) == type(new_utility)):
                     continue
                 
                 self.context.registerUtility(new_utility, provided, name)

Modified: Products.GenericSetup/branches/1.4/Products/GenericSetup/tests/test_components.py
===================================================================
--- Products.GenericSetup/branches/1.4/Products/GenericSetup/tests/test_components.py	2009-04-22 17:56:46 UTC (rev 99395)
+++ Products.GenericSetup/branches/1.4/Products/GenericSetup/tests/test_components.py	2009-04-22 17:57:27 UTC (rev 99396)
@@ -19,6 +19,7 @@
 import Testing
 
 from AccessControl import ClassSecurityInfo
+from Acquisition import Explicit
 from Acquisition import aq_base
 from Globals import InitializeClass
 from OFS.Folder import Folder
@@ -59,7 +60,7 @@
     def verify():
         """Returns True."""
 
-class DummyUtility(object):
+class DummyUtility(Explicit):
     """A dummy utility."""
 
     implements(IDummyInterface)
@@ -122,12 +123,32 @@
 class ComponentRegistryXMLAdapterTests(BodyAdapterTestCase):
 
     layer = ExportImportZCMLLayer
+    _BODY = _COMPONENTS_BODY
 
     def _getTargetClass(self):
         from Products.GenericSetup.components import \
             ComponentRegistryXMLAdapter
         return ComponentRegistryXMLAdapter
 
+    def setUp(self):
+        # Create and enable a local component registry
+        site = Folder()
+        createComponentRegistry(site)
+        setHooks()
+        setSite(site)
+        sm = getSiteManager()
+
+        tool = DummyTool()
+        site._setObject(tool.id, tool)
+
+        tool2 = DummyTool2()
+        site._setObject(tool2.id, tool2)
+
+        self._obj = sm
+
+    def tearDown(self):
+        clearSite()
+
     def _populate(self, obj):
         obj.registerUtility(DummyUtility(), IDummyInterface)
         obj.registerUtility(DummyUtility(), IDummyInterface, name=u'foo')
@@ -167,23 +188,6 @@
         self.assertEqual(tool.meta_type, 'dummy tool2')
         self.assertEquals(repr(aq_base(util)), repr(aq_base(tool)))
 
-    def setUp(self):
-        # Create and enable a local component registry
-        site = Folder()
-        createComponentRegistry(site)
-        setHooks()
-        setSite(site)
-        sm = getSiteManager()
-
-        tool = DummyTool()
-        site._setObject(tool.id, tool)
-
-        tool2 = DummyTool2()
-        site._setObject(tool2.id, tool2)
-
-        self._obj = sm
-        self._BODY = _COMPONENTS_BODY
-
     def test_no_overwrite(self):
         # make sure we don't overwrite an existing tool when it
         # already exists and has the same factory
@@ -208,9 +212,6 @@
         util = queryUtility(IDummyInterface)
         self.assertEquals(getattr(util, 'foo', None), value)
 
-    def tearDown(self):
-        clearSite()
-
 if PersistentComponents is not None:
     def test_suite():
         # reimport to make sure tests are run from Products
@@ -219,6 +220,7 @@
 
         return unittest.TestSuite((
             unittest.makeSuite(ComponentRegistryXMLAdapterTests),
+            #unittest.makeSuite(WrappedComponentRegistryXMLAdapterTests),
             ))
 else:
     def test_suite():



More information about the Checkins mailing list