[Checkins] SVN: Products.GenericSetup/trunk/Products/GenericSetup/ - fixed Zope 2.12 and trunk compatibility

Yvo Schubbe y.2009 at wcm-solutions.de
Sat Jul 4 03:36:42 EDT 2009


Log message for revision 101469:
  - fixed Zope 2.12 and trunk compatibility

Changed:
  U   Products.GenericSetup/trunk/Products/GenericSetup/PluginIndexes/configure.zcml
  U   Products.GenericSetup/trunk/Products/GenericSetup/PluginIndexes/exportimport.py
  U   Products.GenericSetup/trunk/Products/GenericSetup/PluginIndexes/tests/test_exportimport.py
  U   Products.GenericSetup/trunk/Products/GenericSetup/ZCatalog/tests/test_exportimport.py
  U   Products.GenericSetup/trunk/Products/GenericSetup/tests/test_components.py

-=-
Modified: Products.GenericSetup/trunk/Products/GenericSetup/PluginIndexes/configure.zcml
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/PluginIndexes/configure.zcml	2009-07-04 06:13:52 UTC (rev 101468)
+++ Products.GenericSetup/trunk/Products/GenericSetup/PluginIndexes/configure.zcml	2009-07-04 07:36:40 UTC (rev 101469)
@@ -1,5 +1,6 @@
 <configure
-    xmlns="http://namespaces.zope.org/zope">
+    xmlns="http://namespaces.zope.org/zope"
+    xmlns:zcml="http://namespaces.zope.org/zcml">
 
   <adapter factory=".exportimport.PluggableIndexNodeAdapter"/>
 
@@ -9,10 +10,15 @@
 
   <adapter factory=".exportimport.PathIndexNodeAdapter"/>
 
-  <adapter factory=".exportimport.VocabularyNodeAdapter"/>
+  <!-- BBB: for Zope < 2.12 -->
+  <configure zcml:condition="installed Products.PluginIndexes.TextIndex">
 
-  <adapter factory=".exportimport.TextIndexNodeAdapter"/>
+    <adapter factory=".exportimport.VocabularyNodeAdapter"/>
 
+    <adapter factory=".exportimport.TextIndexNodeAdapter"/>
+
+  </configure>
+
   <adapter factory=".exportimport.FilteredSetNodeAdapter"/>
 
   <adapter factory=".exportimport.TopicIndexNodeAdapter"/>

Modified: Products.GenericSetup/trunk/Products/GenericSetup/PluginIndexes/exportimport.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/PluginIndexes/exportimport.py	2009-07-04 06:13:52 UTC (rev 101468)
+++ Products.GenericSetup/trunk/Products/GenericSetup/PluginIndexes/exportimport.py	2009-07-04 07:36:40 UTC (rev 101469)
@@ -28,9 +28,14 @@
 from Products.PluginIndexes.interfaces import IFilteredSet
 from Products.PluginIndexes.interfaces import IPathIndex
 from Products.PluginIndexes.interfaces import IPluggableIndex
-from Products.PluginIndexes.interfaces import ITextIndex
 from Products.PluginIndexes.interfaces import ITopicIndex
-from Products.PluginIndexes.interfaces import IVocabulary
+# BBB: for Zope < 2.12
+try:
+    from Products.PluginIndexes.interfaces import ITextIndex
+    from Products.PluginIndexes.interfaces import IVocabulary
+except ImportError:
+    ITextIndex = None
+    IVocabulary = None
 
 
 class PluggableIndexNodeAdapter(NodeAdapterBase):
@@ -130,6 +135,7 @@
     node = property(_exportNode, lambda self, val: None)
 
 
+# BBB: for Zope < 2.12
 class VocabularyNodeAdapter(NodeAdapterBase):
 
     """Node im- and exporter for Vocabulary.
@@ -147,6 +153,7 @@
     node = property(_exportNode, lambda self, val: None)
 
 
+# BBB: for Zope < 2.12
 class TextIndexNodeAdapter(NodeAdapterBase):
 
     """Node im- and exporter for TextIndex.

Modified: Products.GenericSetup/trunk/Products/GenericSetup/PluginIndexes/tests/test_exportimport.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/PluginIndexes/tests/test_exportimport.py	2009-07-04 06:13:52 UTC (rev 101468)
+++ Products.GenericSetup/trunk/Products/GenericSetup/PluginIndexes/tests/test_exportimport.py	2009-07-04 07:36:40 UTC (rev 101469)
@@ -48,14 +48,6 @@
 <index name="foo_path" meta_type="PathIndex"/>
 """
 
-_VOCABULARY_XML = """\
-<object name="foo_vocabulary" meta_type="Vocabulary" deprecated="True"/>
-"""
-
-_TEXT_XML = """\
-<index name="foo_text" meta_type="TextIndex" deprecated="True"/>
-"""
-
 _SET_XML = """\
 <filtered_set name="bar" meta_type="PythonFilteredSet" expression="True"/>
 """
@@ -164,46 +156,6 @@
         self._XML = _PATH_XML
 
 
-class VocabularyNodeAdapterTests(NodeAdapterTestCase, unittest.TestCase):
-
-    layer = ExportImportZCMLLayer
-
-    def _getTargetClass(self):
-        from Products.GenericSetup.PluginIndexes.exportimport \
-                import VocabularyNodeAdapter
-
-        return VocabularyNodeAdapter
-
-    def setUp(self):
-        from Products.PluginIndexes.TextIndex.Vocabulary import Vocabulary
-
-        self._obj = Vocabulary('foo_vocabulary')
-        self._XML = _VOCABULARY_XML
-
-    def test_importNode(self):
-        pass
-
-
-class TextIndexNodeAdapterTests(NodeAdapterTestCase, unittest.TestCase):
-
-    layer = ExportImportZCMLLayer
-
-    def _getTargetClass(self):
-        from Products.GenericSetup.PluginIndexes.exportimport \
-                import TextIndexNodeAdapter
-
-        return TextIndexNodeAdapter
-
-    def setUp(self):
-        from Products.PluginIndexes.TextIndex.TextIndex import TextIndex
-
-        self._obj = TextIndex('foo_text')
-        self._XML = _TEXT_XML
-
-    def test_importNode(self):
-        pass
-
-
 class FilteredSetNodeAdapterTests(NodeAdapterTestCase, unittest.TestCase):
 
     layer = ExportImportZCMLLayer
@@ -253,8 +205,6 @@
         unittest.makeSuite(FieldIndexNodeAdapterTests),
         unittest.makeSuite(KeywordIndexNodeAdapterTests),
         unittest.makeSuite(PathIndexNodeAdapterTests),
-        unittest.makeSuite(VocabularyNodeAdapterTests),
-        unittest.makeSuite(TextIndexNodeAdapterTests),
         unittest.makeSuite(FilteredSetNodeAdapterTests),
         unittest.makeSuite(TopicIndexNodeAdapterTests),
         ))

Modified: Products.GenericSetup/trunk/Products/GenericSetup/ZCatalog/tests/test_exportimport.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/ZCatalog/tests/test_exportimport.py	2009-07-04 06:13:52 UTC (rev 101468)
+++ Products.GenericSetup/trunk/Products/GenericSetup/ZCatalog/tests/test_exportimport.py	2009-07-04 07:36:40 UTC (rev 101469)
@@ -70,7 +70,7 @@
 _CATALOG_UPDATE_BODY = """\
 <?xml version="1.0"?>
 <object name="foo_catalog">
- <object name="foo_vocabulary" remove="True"/>
+ <object name="old_plexicon" remove="True"/>
  <index name="foo_text" remove="True"/>
  <index name="foo_text" meta_type="ZCTextIndex">
   <indexed_attr value="foo_text"/>
@@ -88,12 +88,16 @@
 # The catalog starts out as the _CATALOG_BODY above with the following
 # xml snippets inserted.
 
-_VOCABULARY_XML = """\
- <object name="foo_vocabulary" meta_type="Vocabulary" deprecated="True"/>
+_LEXICON_XML = """\
+ <object name="old_plexicon" meta_type="ZCTextIndex Lexicon"/>
 """
 
 _TEXT_XML = """\
- <index name="foo_text" meta_type="TextIndex" deprecated="True"/>
+ <index name="foo_text" meta_type="ZCTextIndex">
+  <indexed_attr value="foo_text"/>
+  <extra name="index_type" value="Cosine Measure"/>
+  <extra name="lexicon_id" value="old_plexicon"/>
+ </index>
 """
 
 _COLUMN_XML = """\
@@ -163,11 +167,16 @@
         obj.addColumn('eggs')
 
     def _populate_special(self, obj):
-        from Products.PluginIndexes.TextIndex.Vocabulary import Vocabulary
+        from Products.ZCTextIndex.ZCTextIndex import PLexicon
 
         self._populate(self._obj)
-        obj._setObject('foo_vocabulary', Vocabulary('foo_vocabulary'))
-        obj.addIndex('foo_text', 'TextIndex')
+        obj._setObject('old_plexicon', PLexicon('old_plexicon'))
+
+        extra = _extra()
+        extra.lexicon_id = 'old_plexicon'
+        extra.index_type = 'Cosine Measure'
+        obj.addIndex('foo_text', 'ZCTextIndex', extra)
+
         obj.addColumn('bacon')
 
     def setUp(self):
@@ -182,7 +191,7 @@
         context = DummySetupEnviron()
         adapted = getMultiAdapter((self._obj, context), IBody)
         self.assertEqual(adapted.body,
-                         _CATALOG_BODY % (_VOCABULARY_XML, _TEXT_XML, _COLUMN_XML))
+                       _CATALOG_BODY % (_LEXICON_XML, _TEXT_XML, _COLUMN_XML))
 
     def test_body_set_update(self):
         # Assert that the catalog ends up the way we expect it to.

Modified: Products.GenericSetup/trunk/Products/GenericSetup/tests/test_components.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/tests/test_components.py	2009-07-04 06:13:52 UTC (rev 101468)
+++ Products.GenericSetup/trunk/Products/GenericSetup/tests/test_components.py	2009-07-04 07:36:40 UTC (rev 101469)
@@ -23,13 +23,21 @@
 try:
     from App.class_init import InitializeClass
 except ImportError:
-    # BBB for Zope <2.11
+    # BBB: for Zope < 2.11
     from Globals import InitializeClass
 from OFS.Folder import Folder
 from OFS.SimpleItem import SimpleItem
 from Products.Five.component import enableSite
 from Products.Five.component.interfaces import IObjectManagerSite
-from zope.app.component.hooks import setSite, clearSite, setHooks
+try:
+    from zope.site.hooks import clearSite
+    from zope.site.hooks import setHooks
+    from zope.site.hooks import setSite
+except ImportError:
+    # BBB: for Zope < 2.12
+    from zope.app.component.hooks import clearSite
+    from zope.app.component.hooks import setHooks
+    from zope.app.component.hooks import setSite
 from zope.component import getMultiAdapter
 from zope.component import getGlobalSiteManager
 from zope.component import getSiteManager



More information about the Checkins mailing list