[Checkins] SVN: Products.GenericSetup/branches/1.6/ Accomodate indexes which have no 'indexed_attrs'

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


Log message for revision 129104:
  Accomodate indexes which have no 'indexed_attrs'
  
  E.g., +  Plone's `GopipIndex`.
  

Changed:
  _U  Products.GenericSetup/branches/1.6/
  U   Products.GenericSetup/branches/1.6/Products/GenericSetup/PluginIndexes/exportimport.py
  U   Products.GenericSetup/branches/1.6/Products/GenericSetup/PluginIndexes/tests/test_exportimport.py
  U   Products.GenericSetup/branches/1.6/docs/CHANGES.rst

-=-
Modified: Products.GenericSetup/branches/1.6/Products/GenericSetup/PluginIndexes/exportimport.py
===================================================================
--- Products.GenericSetup/branches/1.6/Products/GenericSetup/PluginIndexes/exportimport.py	2013-01-27 19:04:21 UTC (rev 129103)
+++ Products.GenericSetup/branches/1.6/Products/GenericSetup/PluginIndexes/exportimport.py	2013-01-27 19:05:31 UTC (rev 129104)
@@ -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/branches/1.6/Products/GenericSetup/PluginIndexes/tests/test_exportimport.py
===================================================================
--- Products.GenericSetup/branches/1.6/Products/GenericSetup/PluginIndexes/tests/test_exportimport.py	2013-01-27 19:04:21 UTC (rev 129103)
+++ Products.GenericSetup/branches/1.6/Products/GenericSetup/PluginIndexes/tests/test_exportimport.py	2013-01-27 19:05:31 UTC (rev 129104)
@@ -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

Modified: Products.GenericSetup/branches/1.6/docs/CHANGES.rst
===================================================================
--- Products.GenericSetup/branches/1.6/docs/CHANGES.rst	2013-01-27 19:04:21 UTC (rev 129103)
+++ Products.GenericSetup/branches/1.6/docs/CHANGES.rst	2013-01-27 19:05:31 UTC (rev 129104)
@@ -4,7 +4,9 @@
 1.6.8 (unreleased)
 ------------------
 
-- TBD
+- Accomodate ``PluginIndexes.exportimportPluggableIndexNodeAdapter`` to
+  being registered for indexes which have no ``indexed_attrs`` (e.g.,
+  Plone's ``GopipIndex``).
 
 
 1.6.7 (2013-01-23)



More information about the checkins mailing list