[Zope3-checkins] CVS: Zope3/src/zope/index/keyword - index.py:1.5

Andreas Jung andreas@andreas-jung.com
Sat, 2 Aug 2003 03:51:52 -0400


Update of /cvs-repository/Zope3/src/zope/index/keyword
In directory cvs.zope.org:/tmp/cvs-serv5336

Modified Files:
	index.py 
Log Message:
- made case normalization an attribute of the index
- added CaseSensisitiveKeywordIndex


=== Zope3/src/zope/index/keyword/index.py 1.4 => 1.5 ===
--- Zope3/src/zope/index/keyword/index.py:1.4	Sat Aug  2 03:00:04 2003
+++ Zope3/src/zope/index/keyword/index.py	Sat Aug  2 03:51:48 2003
@@ -26,7 +26,9 @@
 from zope.interface import implements
 
 class KeywordIndex(Persistent):
+    """ A case-insensitive keyword index """
 
+    normalize = True
     implements(IInjection, IStatistics, IKeywordQuerying)
 
     def __init__(self):
@@ -61,7 +63,8 @@
             raise TypeError, 'seq argument must be a list/tuple of strings'
     
         if not seq: return
-        seq = [w.lower() for w in seq]
+        if self.normalize:
+            seq = [w.lower() for w in seq]
 
         old_kw = self._rev_index.get(docid, None)
         new_kw = OOSet(seq)
@@ -122,7 +125,8 @@
         if not isinstance(query, (TupleType, ListType)):
             raise TypeError, 'query argument must be a list/tuple of strings'
 
-        query = [w.lower() for w in query]
+        if self.normalize:
+            query = [w.lower() for w in query]
 
         f = {'and' : intersection, 'or' : union}[operator]
     
@@ -133,4 +137,8 @@
             
         if rs:  return rs
         else: return IISet()
-        
+
+
+class CaseSensitiveKeywordIndex(KeywordIndex):
+    """ A case-sensitive keyword index """
+    normalize = False