[Checkins] SVN: Products.GenericSetup/trunk/ Forward port fix for oddball indexes from 1.6 branch.

Tres Seaver cvs-admin at zope.org
Sun Jan 27 19:11:54 UTC 2013


Log message for revision 129108:
  Forward port fix for oddball indexes from 1.6 branch.

Changed:
  _U  Products.GenericSetup/trunk/
  U   Products.GenericSetup/trunk/Products/GenericSetup/PluginIndexes/exportimport.py
  U   Products.GenericSetup/trunk/Products/GenericSetup/PluginIndexes/tests/test_exportimport.py

-=-
Modified: Products.GenericSetup/trunk/Products/GenericSetup/PluginIndexes/exportimport.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/PluginIndexes/exportimport.py	2013-01-27 19:06:43 UTC (rev 129107)
+++ Products.GenericSetup/trunk/Products/GenericSetup/PluginIndexes/exportimport.py	2013-01-27 19:11:54 UTC (rev 129108)
@@ -50,11 +50,12 @@
         """Import the object from the DOM node.
         """
         indexed_attrs = []
+        _before = getattr(self.context, 'indexed_attrs', [])
         for child in node.childNodes:
             if child.nodeName == 'indexed_attr':
                 indexed_attrs.append(
                                   child.getAttribute('value').encode('utf-8'))
-        if self.context.indexed_attrs != indexed_attrs:
+        if _before != indexed_attrs:
             self.context.indexed_attrs = indexed_attrs
             self.context.clear()
 

Modified: Products.GenericSetup/trunk/Products/GenericSetup/PluginIndexes/tests/test_exportimport.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/PluginIndexes/tests/test_exportimport.py	2013-01-27 19:06:43 UTC (rev 129107)
+++ Products.GenericSetup/trunk/Products/GenericSetup/PluginIndexes/tests/test_exportimport.py	2013-01-27 19:11:54 UTC (rev 129108)
@@ -42,6 +42,11 @@
 </index>
 """
 
+_ODDBALL_XML = """\
+<index name="foo_keyword" meta_type="OddballIndex">
+</index>
+"""
+
 _PATH_XML = """\
 <index name="foo_path" meta_type="PathIndex"/>
 """
@@ -217,6 +222,21 @@
         adapted = PluggableIndexNodeAdapter(index, environ)
         adapted.node = parseString(_KEYWORD_XML).documentElement # no raise
 
+    def test_OddballIndex(self):
+        # Some indexes, e.g. Plone's 'GopipIndex', use ths adapter but don't
+        # have 'indexed_attrs'.
+        from xml.dom.minidom import parseString
+        from Products.GenericSetup.testing import DummySetupEnviron
+        from Products.GenericSetup.PluginIndexes.exportimport \
+                import PluggableIndexNodeAdapter
+        class Oddball(object):
+            def clear(*a):
+                raise AssertionError("Don't clear me!")
+        index = Oddball()
+        environ = DummySetupEnviron()
+        adapted = PluggableIndexNodeAdapter(index, environ)
+        adapted.node = parseString(_ODDBALL_XML).documentElement # no raise
+
     def test_DateIndex(self):
         from xml.dom.minidom import parseString
         from Products.PluginIndexes.DateIndex.DateIndex import DateIndex



More information about the checkins mailing list