Skip to content

Commit

Permalink
Fix get_object_datum for not indexed value support
Browse files Browse the repository at this point in the history
  • Loading branch information
andbag committed May 7, 2019
1 parent 05c8079 commit 2de46a3
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions src/Products/PluginIndexes/unindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@ def clear(self):
self._unindex = IOBTree()

if self.providesNotIndexed(MissingValue):
self._missingvalue_set = IITreeSet()
self._missing_set = IITreeSet()

if self.providesNotIndexed(EmptyValue):
self._emptyvalue_set = IITreeSet()
self._empty_set = IITreeSet()

if self._counter is None:
self._counter = Length()
Expand Down Expand Up @@ -190,24 +190,26 @@ def insertNotIndexed(self, valuetype, documentid):
not_indexed = self.getNotIndexed(valuetype)
return not_indexed.insert(documentid)

def providesNotIndexed(self, valuetype=None):
if valuetype is None:
return (IIndexingMissingValue.providedBy(self) or
IIndexingEmptyValue.providedBy(self))
def providesNotIndexed(self, valuetypes=[MissingValue, EmptyValue]):

if valuetype is MissingValue:
return IIndexingMissingValue.providedBy(self)
if not isinstance(valuetypes, (list, tuple)):
valuetypes = (valuetypes, )

if valuetype is EmptyValue:
return IIndexingEmptyValue.providedBy(self)
if MissingValue in valuetypes \
and IIndexingMissingValue.providedBy(self):
return True

if EmptyValue in valuetypes \
and IIndexingEmptyValue.providedBy(self):
return True

return False

def getNotIndexed(self, valuetype):
if valuetype is MissingValue:
return self._missingvalue_set
return self._missing_set
if valuetype is EmptyValue:
return self._emptyvalue_set
return self._empty_set

raise NotImplementedError

Expand Down Expand Up @@ -301,7 +303,7 @@ def _index_object(self, documentId, obj, threshold=None, attr=''):
# BTrees 4.0+ will throw a TypeError
# "object has default comparison" and won't let it be indexed.
return 0
elif datum is not MissingValue:
elif not isinstance(datum, NotIndexedValue):
datum = self._convert(datum, default=_marker)

# We don't want to do anything that we don't have to here, so we'll
Expand Down Expand Up @@ -350,6 +352,9 @@ def _get_object_datum(self, obj, attr):
return MissingValue
return _marker

if not datum and self.providesNotIndexed(EmptyValue):
return EmptyValue

return datum

def _increment_counter(self):
Expand Down

0 comments on commit 2de46a3

Please sign in to comment.