> I am assuming that the code you provided goes into a
> manage_addCustomIndex method that is part of a CustomIndex
> Python Product.

hehehehe, nothing so general-purpose as that ;-)
> > You will need to implement a subclass derived from one of 
> the standard
> > indexes to provide your custom indexing policy, whatever that is.
> Can you provide the code for your custom KeywordIndex, so I
> have a starting point? I realize yours subclasses a
> KeywordIndex, and I probably need to subclass a TextIndex,
> but it would still probably help. I can integrate and hack
> on other peoples code better than I can write my own from
> scratch.

from SearchIndex.UnKeywordIndex import UnKeywordIndex, MV, intSet
from types import ListType, TupleType

class UnTrackingIndex(UnKeywordIndex):

    meta_type = 'Tracking Properties Index'
    """Like a Keyword Index, only it indexes tracking properties

    def __init__(self,question):
        id = 'tracking_'+unicode(question).encode('unicode-escape')
        self.question = question

    def index_object(self, i, obj, threshold=None):
        """ index an object 'obj' with integer id 'i'"""

        index = self._index
        unindex = self._unindex

            kws = obj.tracking_answers(self.question)
            if type(kws) not in [type([]),type(())]:
                raise ValueError('Indexing a tracking property set of
inappropriate type %r' % type(kws))
            kws = (MV,)
        # index each item in the sequence
        for kw in kws:
            set = index.get(kw)
            if set is None:
                index[kw] = set = intSet()

        unindex[i] = tuple(kws)

        self._index = index
        self._unindex = unindex

        return 1

Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope )

Reply via email to