[Checkins] SVN: Products.GenericSetup/branches/1.3/Products/GenericSetup/ Don't fail when a sub-item cannot be adapted after creation when importing a folder.

Tres Seaver tseaver at palladion.com
Thu Nov 20 13:11:39 EST 2008


Log message for revision 93184:
  Don't fail when a sub-item cannot be adapted after creation when importing a folder.
  
  o https://bugs.launchpad.net/zope-cmf/+bug/300315
  

Changed:
  U   Products.GenericSetup/branches/1.3/Products/GenericSetup/CHANGES.txt
  U   Products.GenericSetup/branches/1.3/Products/GenericSetup/content.py
  U   Products.GenericSetup/branches/1.3/Products/GenericSetup/tests/test_content.py

-=-
Modified: Products.GenericSetup/branches/1.3/Products/GenericSetup/CHANGES.txt
===================================================================
--- Products.GenericSetup/branches/1.3/Products/GenericSetup/CHANGES.txt	2008-11-20 18:07:23 UTC (rev 93183)
+++ Products.GenericSetup/branches/1.3/Products/GenericSetup/CHANGES.txt	2008-11-20 18:11:38 UTC (rev 93184)
@@ -2,6 +2,9 @@
 
   After GenericSetup 1.3.4
 
+    - Don't fail when a sub-item cannot be adapted after creation when
+      importing a folder.  (https://bugs.launchpad.net/zope-cmf/+bug/300315)
+
     - Avoid even an explicit purge of the rolemap if no XML file is present
       in a given context.  (https://bugs.launchpad.net/zope-cmf/+bug/279294)
 

Modified: Products.GenericSetup/branches/1.3/Products/GenericSetup/content.py
===================================================================
--- Products.GenericSetup/branches/1.3/Products/GenericSetup/content.py	2008-11-20 18:07:23 UTC (rev 93183)
+++ Products.GenericSetup/branches/1.3/Products/GenericSetup/content.py	2008-11-20 18:11:38 UTC (rev 93184)
@@ -179,7 +179,9 @@
 
             wrapped = context._getOb(object_id)
 
-            IFilesystemImporter(wrapped).import_(import_context, subdir)
+            adapted = queryAdapter(wrapped, IFilesystemImporter)
+            if adapted is not None:
+                adapted.import_(import_context, subdir)
 
     def _makeInstance(self, instance_id, type_name, subdir, import_context):
 

Modified: Products.GenericSetup/branches/1.3/Products/GenericSetup/tests/test_content.py
===================================================================
--- Products.GenericSetup/branches/1.3/Products/GenericSetup/tests/test_content.py	2008-11-20 18:07:23 UTC (rev 93183)
+++ Products.GenericSetup/branches/1.3/Products/GenericSetup/tests/test_content.py	2008-11-20 18:11:38 UTC (rev 93184)
@@ -549,6 +549,25 @@
         for found_id, expected_id in zip(after, ITEM_IDS):
             self.assertEqual(found_id, expected_id)
 
+    def test_import_site_with_subitems_wo_adapter(self):
+        from Products.GenericSetup.utils import _getDottedName
+        item = _makeItem('no_adapter')
+        dotted = _getDottedName(item.__class__)
+        self._setUpAdapters()
+
+        site = _makeFolder('site')
+
+        context = DummyImportContext(site)
+        # We want to add 'baz' to 'foo', without losing 'bar'
+        context._files['structure/.objects'] = '\n'.join(
+                            ['%s,%s' % (x, dotted) for x in ('no_adapter',)])
+        importer = self._getImporter()
+        importer(context)
+
+        after = site.objectIds()
+        self.assertEqual(len(after), 1)
+        self.assertEqual(after[0], 'no_adapter')
+
     def test_import_site_with_subitems_and_blanklines_dotobjects(self):
         from Products.GenericSetup.utils import _getDottedName
         from faux_objects import KNOWN_INI



More information about the Checkins mailing list