Skip to content

Commit

Permalink
uniqueValuesFor check by IUniqueValueIndex.providedBy
Browse files Browse the repository at this point in the history
  • Loading branch information
andbag committed Oct 5, 2010
1 parent bee731e commit dcb7e5c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Products/ZCatalog/Catalog.py
Expand Up @@ -24,6 +24,7 @@
from Missing import MV
from Persistence import Persistent
from Products.PluginIndexes.interfaces import ILimitedResultIndex
from Products.PluginIndexes.interfaces import IUniqueValueIndex
from Products.PluginIndexes.interfaces import ITransposeQuery

import BTrees.Length
Expand Down Expand Up @@ -395,10 +396,16 @@ def uncatalogObject(self, uid):
'attempted to uncatalog an object '
'with a uid of %s. ' % str(uid))


def uniqueValuesFor(self, name):
""" return unique values for FieldIndex name """
return self.getIndex(name).uniqueValues()

indexes = self.indexes.keys()
for idx in indexes:
x = self.getIndex(idx)
if IUniqueValueIndex.providedBy(x) and x.hasUniqueValuesFor(name):
return x.uniqueValues(name=name)

return []

def hasuid(self, uid):
""" return the rid if catalog contains an object with uid """
Expand Down

0 comments on commit dcb7e5c

Please sign in to comment.