[Zope] Catalog and CatalogAware questions

Kevin Dangoor kid@kendermedia.com
Mon, 15 May 2000 13:44:05 -0400


----- Original Message -----
From: "ed colmar" <element@immersivearts.com>
To: <zope@zope.org>
Sent: Saturday, May 13, 2000 12:54 PM
Subject: [Zope] Catalog and CatalogAware questions


> I am trying to grok the Catalog and CatalogAware classes.  I don't quite
> understand how to map variables into it.

In general, you just have to add indexes to your Catalog for the properties
that you want to be able to search on. You may also want to add properties
to the metadata table, so that you can use the metadata for fast display of
a lot of information.

> Say for instance that I have two classes within my base class that contain
> different variables:
>
> * people class contains the variables name, birthday, and djname
> * event class contains the variables eventname, startdate, and dj_list
>
> Now, I want to be able to search for an "eventname", which would not need
> to look in the people class at all.  I also want to be able to search for
a
> dj, which would look in both classes for the variables "djname" and
> "dj_list", and bring back all the matches.  How is it that these
> definitions are created?

You can create indexes for all of these. If an object does not have a given
property, no value is stored for that property for that object.

> I have tried setting up my base class to inherit Catalog, which gave me no
> errors, but I don't think I initialized it correctly.  I tried inheriting
> CatalogAware, which gave me strange results, but I could see it when I
> would add a search interface from the management screen.

You don't really need to inherit Catalog. Usually, you'll put a ZCatalog
(often called Catalog) in your Zope hierarchy that you can get to via
acquisition. If you inherit CatalogAware, your objects will automatically be
added to this catalog when they are added to the ZODB.

Does this clear things up at all?

Kevin