[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/TextIndex - Lexicon.py:1.3
Andreas Jung
andreas@zope.com
Thu, 11 Oct 2001 08:19:41 -0400
Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/TextIndex
In directory cvs.zope.org:/tmp/cvs-serv28884
Modified Files:
Lexicon.py
Log Message:
Strings were stored in the Lexicon using the intern() function
to provide some minor speedup. But this made it impossible to
store unicode strings. So we can now store unicode strings
in a Lexicon *yippi*
=== Zope/lib/python/Products/PluginIndexes/TextIndex/Lexicon.py 1.2 => 1.3 ===
from randid import randid
+from types import StringType
class Lexicon(Persistent, Implicit):
"""Maps words to word ids and then some
@@ -198,7 +199,11 @@
while not inverse.insert(wid, word):
wid=randid()
- self._lexicon[intern(word)] = wid
+ if isinstance(word,StringType):
+ self._lexicon[intern(word)] = wid
+ else:
+ self._lexicon[word] = wid
+
return wid