[Zope] ZCatalog, CatalogAware, and ZClasses

gtk gtk@well.com
Wed, 13 Oct 1999 12:42:56 +1000


I'm trying to expand on the ZCatalog tutorial at
http://www.zope.org/Documentation/How-To/ZCatalogTutorial by creating a
ZClass which automatically maintains a catalog of the CatalogAware items
within it.

So far, I've created:

    FnordProduct: Product
        FnordContainerClass: ZClass derived from ObjectManager
                Catalog: ZCatalog
                FnordClass: ZClass derived from CatalogAware

... along with a <classname>Info property sheet each and a matching View to
boot.

Surprise! When I create a FnordContainer and populate it, the Fnords inside
it are catalogued in the ZCatalog in the product. That looks like
inheritance (sorry, acquisition:) in action.

I assume I need to doctor the FnordContainerClass_add method to create a new
ZCatalog in the new FnordContainer. How do I do that?

CatalogAwareness.py also mentions:

    This is a Mix-In class to make objects automaticly catalog and
    uncatalog themselves in Zope, and to provide some other basic
    attributes that are useful to catalog.  Note that if your class or
    ZClass subclasses CatalogAware, it will only catalog itself when
    it is added or copied in Zope.  If you make changes to your own
    object, you are responsible for calling your object's index_object
    method.

Uh, fine. At the moment, I'm only editing my Fnords via their Properties
view. How do I doctor the view so that index_object is called?

Finally; I've added an index_html method to my FnordContainerClass and used
the Z Search Interface pseudo-product (all it does is create DTML methods,
and one day I'll investigate and find out how the beggars did it) to create
search and results methods.

For some reason, it can't find any of the items in the Catalog. Wierd. Any
ideas?

Regards,
Garth.

--
<gtk@well.com>