[Checkins] SVN: Products.GenericSetup/branches/1.3/Products/GenericSetup/ - content: Add simple guard against import failures when

Jens Vagelpohl jens at dataflake.org
Sun Dec 30 07:33:52 EST 2007


Log message for revision 82571:
  - 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.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	2007-12-30 12:23:10 UTC (rev 82570)
+++ Products.GenericSetup/branches/1.3/Products/GenericSetup/CHANGES.txt	2007-12-30 12:33:52 UTC (rev 82571)
@@ -1,5 +1,12 @@
 GenericSetup Product Changelog
 
+  GenericSetup 1.3.4 (unreleased)
+
+    - content: Add simple guard against import failures when
+      the ".objects" file contains empty lines.
+      (https://bugs.launchpad.net/zope-cmf/+bug/176328)
+
+
   GenericSetup 1.3.3 (2007/12/29)
 
     - Be more careful in checking context id validity.

Modified: Products.GenericSetup/branches/1.3/Products/GenericSetup/content.py
===================================================================
--- Products.GenericSetup/branches/1.3/Products/GenericSetup/content.py	2007-12-30 12:23:10 UTC (rev 82570)
+++ Products.GenericSetup/branches/1.3/Products/GenericSetup/content.py	2007-12-30 12:33:52 UTC (rev 82571)
@@ -162,10 +162,11 @@
         stream = StringIO(objects)
 
         rowiter = reader(stream, dialect)
+        rows = filter(None, tuple(rowiter))
 
         existing = context.objectIds()
 
-        for object_id, type_name in rowiter:
+        for object_id, type_name in rows:
 
             if object_id not in existing:
                 object = self._makeInstance(object_id, type_name,

Modified: Products.GenericSetup/branches/1.3/Products/GenericSetup/tests/test_content.py
===================================================================
--- Products.GenericSetup/branches/1.3/Products/GenericSetup/tests/test_content.py	2007-12-30 12:23:10 UTC (rev 82570)
+++ Products.GenericSetup/branches/1.3/Products/GenericSetup/tests/test_content.py	2007-12-30 12:33:52 UTC (rev 82571)
@@ -549,6 +549,35 @@
         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):
+        from Products.GenericSetup.utils import _getDottedName
+        from faux_objects import KNOWN_INI
+        from faux_objects import TestINIAware
+        dotted = _getDottedName(TestINIAware)
+        self._setUpAdapters()
+        ITEM_IDS = ('foo', 'bar', 'baz')
+
+        site = _makeFolder('site')
+
+        context = DummyImportContext(site)
+        # We want to add 'baz' to 'foo', without losing 'bar'
+        correct = '\n'.join(['%s,%s' % (x, dotted) 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):
         from faux_objects import KNOWN_INI
         self._setUpAdapters()



More information about the Checkins mailing list