Commit 680fb65b authored by Casey Duncan's avatar Casey Duncan

Merging pluginindex cleanup into the head

parent 2167f3f6
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
############################################################################## ##############################################################################
"""$Id: DateIndex.py,v 1.8 2002/10/01 14:09:47 gvanrossum Exp $ """$Id: DateIndex.py,v 1.9 2002/12/05 21:35:52 caseman Exp $
""" """
from DateTime.DateTime import DateTime from DateTime.DateTime import DateTime
...@@ -32,7 +32,8 @@ _marker = [] ...@@ -32,7 +32,8 @@ _marker = []
class DateIndex(UnIndex): class DateIndex(UnIndex):
""" Index for Dates """ """ Index for Dates """
__implements__ = (PluggableIndex.PluggableIndexInterface,) __implements__ = (PluggableIndex.UniqueValueIndex,
PluggableIndex.SortIndex)
meta_type = 'DateIndex' meta_type = 'DateIndex'
query_options = ['query', 'range'] query_options = ['query', 'range']
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
############################################################################## ##############################################################################
"""$Id: DateRangeIndex.py,v 1.4 2002/08/14 22:19:28 mj Exp $ """$Id: DateRangeIndex.py,v 1.5 2002/12/05 21:35:52 caseman Exp $
""" """
from Products.PluginIndexes import PluggableIndex from Products.PluginIndexes import PluggableIndex
...@@ -52,7 +52,9 @@ class DateRangeIndex(UnIndex): ...@@ -52,7 +52,9 @@ class DateRangeIndex(UnIndex):
- Objects which match only during a specific interval. - Objects which match only during a specific interval.
""" """
__implements__ = ( PluggableIndex.PluggableIndexInterface, )
__implements__ = (PluggableIndex.UniqueValueIndex,
PluggableIndex.SortIndex)
security = ClassSecurityInfo() security = ClassSecurityInfo()
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
"""Simple column indices """Simple column indices
$Id: FieldIndex.py,v 1.10 2002/08/14 22:19:29 mj Exp $ $Id: FieldIndex.py,v 1.11 2002/12/05 21:35:52 caseman Exp $
""" """
from Products.PluginIndexes import PluggableIndex from Products.PluginIndexes import PluggableIndex
...@@ -24,7 +24,8 @@ from Globals import DTMLFile ...@@ -24,7 +24,8 @@ from Globals import DTMLFile
class FieldIndex(UnIndex): class FieldIndex(UnIndex):
"""Field Indexes""" """Field Indexes"""
__implements__ = (PluggableIndex.PluggableIndexInterface,) __implements__ = (PluggableIndex.UniqueValueIndex,
PluggableIndex.SortIndex)
meta_type="FieldIndex" meta_type="FieldIndex"
......
...@@ -21,7 +21,8 @@ from Products.PluginIndexes.common.UnIndex import UnIndex ...@@ -21,7 +21,8 @@ from Products.PluginIndexes.common.UnIndex import UnIndex
class KeywordIndex(UnIndex): class KeywordIndex(UnIndex):
__implements__ = (PluggableIndex.PluggableIndexInterface,) __implements__ = (PluggableIndex.UniqueValueIndex,
PluggableIndex.SortIndex)
meta_type="KeywordIndex" meta_type="KeywordIndex"
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
############################################################################## ##############################################################################
__version__ = '$Id: PathIndex.py,v 1.29 2002/11/28 13:03:11 beacon Exp $' __version__ = '$Id: PathIndex.py,v 1.30 2002/12/05 21:35:53 caseman Exp $'
from Products.PluginIndexes import PluggableIndex from Products.PluginIndexes import PluggableIndex
from Products.PluginIndexes.common.util import parseIndexRequest from Products.PluginIndexes.common.util import parseIndexRequest
...@@ -44,7 +44,7 @@ class PathIndex(Persistent, Implicit, SimpleItem): ...@@ -44,7 +44,7 @@ class PathIndex(Persistent, Implicit, SimpleItem):
""" """
__implements__ = (PluggableIndex.PluggableIndexInterface,) __implements__ = (PluggableIndex.UniqueValueIndex,)
meta_type="PathIndex" meta_type="PathIndex"
...@@ -328,6 +328,12 @@ class PathIndex(Persistent, Implicit, SimpleItem): ...@@ -328,6 +328,12 @@ class PathIndex(Persistent, Implicit, SimpleItem):
else: else:
return IISet(), (self.id,) return IISet(), (self.id,)
def hasUniqueValuesFor(self, name):
"""has unique values for column name"""
if name == self.id:
return 1
else:
return 0
def uniqueValues(self,name=None,withLength=0): def uniqueValues(self,name=None,withLength=0):
""" needed to be consistent with the interface """ """ needed to be consistent with the interface """
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
############################################################################## ##############################################################################
__version__ = '$Id: TopicIndex.py,v 1.10 2002/11/28 16:32:02 andreasjung Exp $' __version__ = '$Id: TopicIndex.py,v 1.11 2002/12/05 21:35:53 caseman Exp $'
from Products.PluginIndexes import PluggableIndex from Products.PluginIndexes import PluggableIndex
from Products.PluginIndexes.common.util import parseIndexRequest from Products.PluginIndexes.common.util import parseIndexRequest
...@@ -94,7 +94,8 @@ class TopicIndex(Persistent, Implicit, SimpleItem): ...@@ -94,7 +94,8 @@ class TopicIndex(Persistent, Implicit, SimpleItem):
return n return n
numObjects = "does not apply" def numObjects(self):
return "N/A"
def keys(self): pass def keys(self): pass
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
# #
############################################################################## ##############################################################################
"""Pluggable Index Base Class """ """Pluggable Index Interface"""
__version__='$Revision: 1.7 $'[11:-2] __version__='$Revision: 1.8 $'[11:-2]
import Interface import Interface
...@@ -36,14 +36,6 @@ class PluggableIndexInterface(Interface.Base): ...@@ -36,14 +36,6 @@ class PluggableIndexInterface(Interface.Base):
def unindex_object(documentId): def unindex_object(documentId):
"""Remove the documentId from the index.""" """Remove the documentId from the index."""
# XXX TextIndex does not implement uniqueValues().
def uniqueValues(name=None, withLengths=0):
"""Returns the unique values for name.
If 'withLengths' is true, returns a sequence of tuples of
(value, length).
"""
def _apply_index(request, cid=''): def _apply_index(request, cid=''):
"""Apply the index to query parameters given in 'request'. """Apply the index to query parameters given in 'request'.
...@@ -67,3 +59,34 @@ class PluggableIndexInterface(Interface.Base): ...@@ -67,3 +59,34 @@ class PluggableIndexInterface(Interface.Base):
records. The second object is a tuple containing the names of records. The second object is a tuple containing the names of
all data fields used. all data fields used.
""" """
def numObjects():
"""Return the number of indexed objects"""
def clear():
"""Empty the index"""
class UniqueValueIndex(PluggableIndexInterface):
"""An index which can return lists of unique values contained in it"""
def hasUniqueValuesFor(name):
"""Return true if the index can return the unique values for name"""
def uniqueValues(name=None, withLengths=0):
"""Return the unique values for name.
If 'withLengths' is true, returns a sequence of tuples of
(value, length)."""
class SortIndex(PluggableIndexInterface):
"""An index which may be used to sort a set of document ids"""
def keyForDocument(documentId):
"""Return the sort key that cooresponds to the specified document id
This method is no longer used by ZCatalog, but is left for backwards
compatibility."""
def documentToKeyMap():
"""Return an object that supports __getitem__ and may be used to quickly
lookup the sort key given a document id"""
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
"""Simple column indices""" """Simple column indices"""
__version__='$Revision: 1.15 $'[11:-2] __version__='$Revision: 1.16 $'[11:-2]
from Globals import Persistent from Globals import Persistent
from Acquisition import Implicit from Acquisition import Implicit
...@@ -383,7 +383,7 @@ class UnIndex(Persistent, Implicit, SimpleItem): ...@@ -383,7 +383,7 @@ class UnIndex(Persistent, Implicit, SimpleItem):
return r, (self.id,) return r, (self.id,)
def hasUniqueValuesFor(self, name): def hasUniqueValuesFor(self, name):
' has unique values for column NAME ' """has unique values for column name"""
if name == self.id: if name == self.id:
return 1 return 1
else: else:
...@@ -413,11 +413,15 @@ class UnIndex(Persistent, Implicit, SimpleItem): ...@@ -413,11 +413,15 @@ class UnIndex(Persistent, Implicit, SimpleItem):
else: else:
l = len(set) l = len(set)
rl.append((i, l)) rl.append((i, l))
return tuple(rl) return tuple(rl)
def keyForDocument(self, id): def keyForDocument(self, id):
# This method is superceded by documentToKeyMap
return self._unindex[id] return self._unindex[id]
def documentToKeyMap(self):
return self._unindex
def items(self): def items(self):
items = [] items = []
for k,v in self._index.items(): for k,v in self._index.items():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment