[Checkins] SVN: Products.CMFCore/trunk/Products/CMFCore/exportimport/ - exportimport.content: Add simple guard against import failures when

Jens Vagelpohl jens at dataflake.org
Sun Dec 30 07:23:11 EST 2007


Log message for revision 82570:
  - exportimport.content: Add simple guard against import failures when
    the ".objects" file contains empty lines.
    (https://bugs.launchpad.net/zope-cmf/+bug/176328)
  

Changed:
  U   Products.CMFCore/trunk/Products/CMFCore/exportimport/content.py
  U   Products.CMFCore/trunk/Products/CMFCore/exportimport/tests/test_content.py

-=-
Modified: Products.CMFCore/trunk/Products/CMFCore/exportimport/content.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/exportimport/content.py	2007-12-30 12:21:47 UTC (rev 82569)
+++ Products.CMFCore/trunk/Products/CMFCore/exportimport/content.py	2007-12-30 12:23:10 UTC (rev 82570)
@@ -131,7 +131,7 @@
         stream = StringIO(objects)
 
         rowiter = reader(stream, dialect)
-        ours = tuple(rowiter)
+        ours = filter(None, tuple(rowiter))
         our_ids = set([item[0] for item in ours])
 
         prior = set(context.contentIds())

Modified: Products.CMFCore/trunk/Products/CMFCore/exportimport/tests/test_content.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/exportimport/tests/test_content.py	2007-12-30 12:21:47 UTC (rev 82569)
+++ Products.CMFCore/trunk/Products/CMFCore/exportimport/tests/test_content.py	2007-12-30 12:23:10 UTC (rev 82570)
@@ -406,6 +406,31 @@
         for found_id, expected_id in zip(after, ITEM_IDS):
             self.assertEqual(found_id, expected_id)
 
+    def test_import_site_with_subitems_and_blanklines_dotobjects(self):
+        self._setUpAdapters()
+        ITEM_IDS = ('foo', 'bar', 'baz')
+
+        site = _makeFolder('site', site_folder=True)
+
+        context = DummyImportContext(site)
+        # We want to add 'baz' to 'foo', without losing 'bar'
+        correct = '\n'.join(['%s,%s' % (x, TEST_INI_AWARE) for x in ITEM_IDS])
+        broken = correct + '\n\n'
+        context._files['structure/.objects'] = broken
+        for index in range(len(ITEM_IDS)):
+            id = ITEM_IDS[index]
+            context._files[
+                    'structure/%s.ini' % id] = KNOWN_INI % ('Title: %s' % id,
+                                                            'xyzzy',
+                                                           )
+        importer = self._getImporter()
+        importer(context)
+
+        after = site.objectIds()
+        self.assertEqual(len(after), len(ITEM_IDS))
+        for found_id, expected_id in zip(after, ITEM_IDS):
+            self.assertEqual(found_id, expected_id)
+
     def test_import_site_with_subitem_unknown_portal_type(self):
         self._setUpAdapters()
         ITEM_IDS = ('foo', 'bar', 'baz')



More information about the Checkins mailing list