[Zope-dev] Pluggable Index How-To Questions

Chris Withers chrisw@nipltd.com
Tue, 12 Jun 2001 15:14:03 +0100


Andreas Jung wrote:
> 
> > Is there anything you can do in the index_object method to re-use
> ZCatalog's
> > "get all attributes and call them if they're callable"?
> 
> Don't understand the question...maybe I don't know this ZCatalog feature.

My perception is that the 'classic' ZCatalog Indexes have a method something
like:

def getValue(self,obj):
  try:
    value = getattr(obj,self.id) # self.id is the name of the index. 
                                 # The interface doesn't specify how to 
                                 # get hold of this :-S
    if callable(value):
      value=value()
  except AttributeError,TypeError:
      value=None
  return value

...which gets the value to index. I was wondering if that function is available
anywhere rather than having to re-implement it each time you write a new
pluggable index. That said, I guess the 'classic' indexes have been
re-implemented as PluggableIndexes?

> > In uniqueValues, what do the lengths that withLengths returns actually
> mean?
> 
> Good question  - I think uniqueValues is only used for FieldIndex. I think
> you usually must not implement it - I must check this...

Well, IMHO, uniqueValues shouldn't be part of the interface. AFAIK, it only
makes sense with certain types of index: KeywordIdnexes and possibly
FieldIndexes. Is that the case?

> > In _apply_index, are ResultSet objects and how to build them documented
> > anywhere? What is cid used for?
> 
> Best way is to take a look in PathIndex.py..

OK :-)

> There is a new API for passing parameters to the searchResults() of the
> ZCatalog
> (see ZCatalog/help/ZCatalog_Parameters.stx and doc/changenotes). The
> query_options
>  is a list of options that the index is interested when it gets a search
> request.

OK...

> > How abotu a 'Generic Pluggable Index' that lets you implement the
> interface
> > using Python Scripts, ZSQL methods, etc?
> 
> uuuuuuuhhhhhhhhhhhhh.....I think you can write that as a Product.

hehe... cool :-)

> But I
> don't think
> we will write this. And I don't like the idea...I prefer to write such a
> package
> with VI and store it in the filesystem :-)

I agree, but when you're exploring what you want to do and don't have access to
the filesystem, it could be really useful.

thanks for the answers,

Chris