Log message for revision 105033:
  Merged Zope/branches/tyam-unicodeSplitterPatch 104723:104761

Changed:
  U   Zope/branches/2.12/src/Products/ZCTextIndex/Lexicon.py
  U   Zope/branches/2.12/src/Products/ZCTextIndex/tests/testLexicon.py

-=-
Modified: Zope/branches/2.12/src/Products/ZCTextIndex/Lexicon.py
===================================================================
--- Zope/branches/2.12/src/Products/ZCTextIndex/Lexicon.py      2009-10-13 
09:18:10 UTC (rev 105032)
+++ Zope/branches/2.12/src/Products/ZCTextIndex/Lexicon.py      2009-10-13 
09:23:58 UTC (rev 105033)
@@ -76,7 +76,8 @@
     def termToWordIds(self, text):
         last = _text2list(text)
         for element in self._pipeline:
-            last = element.process(last)
+            process = getattr(element, "process_post_glob", element.process) 
+            last = process(last)
         wids = []
         for word in last:
             wids.append(self._wids.get(word, 0))

Modified: Zope/branches/2.12/src/Products/ZCTextIndex/tests/testLexicon.py
===================================================================
--- Zope/branches/2.12/src/Products/ZCTextIndex/tests/testLexicon.py    
2009-10-13 09:18:10 UTC (rev 105032)
+++ Zope/branches/2.12/src/Products/ZCTextIndex/tests/testLexicon.py    
2009-10-13 09:23:58 UTC (rev 105033)
@@ -94,6 +94,28 @@
         wids = lexicon.termToWordIds('boxes')
         self.assertEqual(wids, [0])
 
+    def testTermToWordIdsWithProcess_post_glob(self):
+        """This test is for added process_post_glob"""
+        class AddedSplitter(Splitter):
+            def process_post_glob(self, lst):
+                assert lst == ['dogs']
+                return ['dogs']
+        lexicon = Lexicon(AddedSplitter())
+        wids = lexicon.sourceToWordIds('cats and dogs')
+        wids = lexicon.termToWordIds('dogs')
+        self.assertEqual(wids, [3])
+
+    def testMissingTermToWordIdsWithProcess_post_glob(self):
+        """This test is for added process_post_glob"""
+        class AddedSplitter(Splitter):
+            def process_post_glob(self, lst):
+                assert lst == ['dogs']
+                return ['fox']
+        lexicon = Lexicon(AddedSplitter())
+        wids = lexicon.sourceToWordIds('cats and dogs')
+        wids = lexicon.termToWordIds('dogs')
+        self.assertEqual(wids, [0])
+
     def testOnePipelineElement(self):
         lexicon = Lexicon(Splitter(), StupidPipelineElement('dogs', 'fish'))
         wids = lexicon.sourceToWordIds('cats and dogs')

_______________________________________________
Zope-Checkins maillist  -  Zope-Checkins@zope.org
https://mail.zope.org/mailman/listinfo/zope-checkins

Reply via email to