[Checkins] SVN: Products.GenericSetup/trunk/Products/GenericSetup/
- content: Add simple guard against import failures when
Jens Vagelpohl
jens at dataflake.org
Sun Dec 30 07:38:04 EST 2007
Log message for revision 82572:
- 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/trunk/Products/GenericSetup/content.py
U Products.GenericSetup/trunk/Products/GenericSetup/tests/test_content.py
-=-
Modified: Products.GenericSetup/trunk/Products/GenericSetup/content.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/content.py 2007-12-30 12:33:52 UTC (rev 82571)
+++ Products.GenericSetup/trunk/Products/GenericSetup/content.py 2007-12-30 12:38:03 UTC (rev 82572)
@@ -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/trunk/Products/GenericSetup/tests/test_content.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/tests/test_content.py 2007-12-30 12:33:52 UTC (rev 82571)
+++ Products.GenericSetup/trunk/Products/GenericSetup/tests/test_content.py 2007-12-30 12:38:03 UTC (rev 82572)
@@ -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