[CMF-checkins] SVN: CMF/trunk/GenericSetup/t If we can acquire something from a parent of the site and it's class doesn't match what we're trying to create as a tool, don't try to delete it first.

Chris McDonough chrism at plope.com
Tue Nov 1 22:45:35 EST 2005


Log message for revision 39840:
  If we can acquire something from a parent of the site and it's class doesn't match what we're trying to create as a tool, don't try to delete it first.
  
  

Changed:
  U   CMF/trunk/GenericSetup/tests/test_tool.py
  U   CMF/trunk/GenericSetup/tool.py

-=-
Modified: CMF/trunk/GenericSetup/tests/test_tool.py
===================================================================
--- CMF/trunk/GenericSetup/tests/test_tool.py	2005-11-02 00:53:22 UTC (rev 39839)
+++ CMF/trunk/GenericSetup/tests/test_tool.py	2005-11-02 03:45:34 UTC (rev 39840)
@@ -853,7 +853,42 @@
         self.failUnless( isinstance( aq_base( site._getOb( 'obligatory' ) )
                                    , DummyTool ) )
 
+    def test_required_tools_missing_acquired_nofail( self ):
 
+        from Products.GenericSetup.tool import TOOLSET_XML
+        from Products.GenericSetup.tool import importToolset
+
+        site = self._initSite()
+        parent_site = Folder()
+
+        mandatory = AnotherDummyTool()
+        mandatory._setId( 'mandatory' )
+        parent_site._setObject( 'mandatory', mandatory )
+
+        obligatory = AnotherDummyTool()
+        obligatory._setId( 'obligatory' )
+        parent_site._setObject( 'obligatory', obligatory )
+
+        site = site.__of__(parent_site)
+
+        # acquiring subobjects of a different class during import
+        # should not prevent new objects from being created if they
+        # don't exist in the site
+
+        context = DummyImportContext( site, tool=site.setup_tool )
+        context._files[ TOOLSET_XML ] = _REQUIRED_TOOLSET_XML
+
+        importToolset( context )
+
+        self.failIf( aq_base( site._getOb( 'mandatory' ) ) is mandatory )
+        self.failUnless( isinstance( aq_base( site._getOb( 'mandatory' ) )
+                                   , DummyTool ) )
+
+        self.failIf( aq_base( site._getOb( 'obligatory' ) ) is obligatory )
+        self.failUnless( isinstance( aq_base( site._getOb( 'obligatory' ) )
+                                   , DummyTool ) )
+
+
 class DummyTool( Folder ):
 
     pass

Modified: CMF/trunk/GenericSetup/tool.py
===================================================================
--- CMF/trunk/GenericSetup/tool.py	2005-11-02 00:53:22 UTC (rev 39839)
+++ CMF/trunk/GenericSetup/tool.py	2005-11-02 03:45:34 UTC (rev 39840)
@@ -90,7 +90,7 @@
         tool_id = str(info['id'])
         tool_class = _resolveDottedName(info['class'])
 
-        existing = getattr(site, tool_id, None)
+        existing = getattr(aq_base(site), tool_id, None)
         new_tool = tool_class()
 
         try:



More information about the CMF-checkins mailing list