[Zope3-dev] a simple product

Steve Alexander steve@cat-box.net
Mon, 20 Jan 2003 18:15:56 +0200


> Both indexes derive, like FieldIndex and KeywordIndex, from UnIndex;
> porting the whole package is probably not that much harder than porting
> only one index.

Well, perhaps someone is interested in porting the Zope2 'unindexes' to 
Zope 3.

I hope that someone does so, and also in doing so they:

* Rename confusing terms like using 'unindex' for the base class of
   indexes.

* Take account of the new datetime package in Zope 3, and its
   distinction between dates, times, and datetimes.

* Not get attributes from objects to be indexed, but instead, adapt
   the objects to an interface like IDateRangeIndexable, and index based
   on that.

This could be an opportunity to use named adapters.

Let's say IDateRangeIndexable looks like this:

   class IDateRangeIndexable(Interface):
       start = Attribute('Start date')
       end = Attribute('End date')

Let's say I have a VacationAnnouncement content-type. I use this content 
type to tell my colleagues when I'll be on vacation. A 
VacationAnnouncement has two date ranges of importance.

* Common to all announcements, the dates when the announcement is
   pertinent.

* Common to all vacations, the dates I'll actually be away.

If I want to index both these ranges, in separate indexes, I can do so.

Configure my announcement index like this:

* Adapt objects to be indexed with
   getAdapter(obj, IDateRangeIndexable, name='announcement')


Configure my vacations index like this:

* Adapt objects to be indexed with
   getAdapter(obj, IDateRangeIndexable, name='vacation')

(I could used dotted names if I thought it was important to avoid naming 
collisions.)

So, each type of index has an associated interface for the kind of thing 
it indexes, and each instance is configured with the name of the adapter 
to get.


(The IDateRangeIndexable is only an example. I'm sure the Date indexes 
will need more analysis.)

--
Steve Alexander