[ZPT] Are PT's ZCatelog Aware? - Now: Subclassing ZPT's

Evan Simpson evan@digicool.com
Wed, 4 Jul 2001 23:26:59 -0500


From: "Lynn Walton" <waltonl@babbage.franklin.edu>
> Thanks for the opinions. I must admit this is discouraging to me. At
least
> to hear that the ZCatalog and related stuff is tricking and somewhat
> broken.  One of several reasons I chose zope is because of the
automatic
> indexing abilities.   It seems to me that if PageTemplates are to be a
> viable replacement for DTML documents, then being able to be cataloged
for
> indexing is a must. Otherwise your saying that any site choosing ZPT
over
> DTML has to give up being searchable? That's not going to be
acceptable for
> my site and I would guess not for many other sites either.

I think I've really given you the wrong impression.  My warnings have
nothing to do with ZPT vs. DTML, or even ZCatalog in general.  You
should be able to catalog and search on ZPT objects just fine, as you
would any other Zope object.  It's the CatalogAware mixin, that tries to
make objects automagically catalog and uncatalog themselves, which is
the problem.  There's a newer CatalogAwareness (I think) mixin class
that solves some of the technical problems, but the more fundamental one
comes from the fact that metadata and index references stored in a
ZCatalog don't get updated unless the ZCatalog is instructed that the
object has changed.  The old mixin class only touches the ZCatalog when
the object is created, deleted, or moved, not when it is changed in
place.  This means that you need to do some work in the subclass to kick
the catalog whenever the object changes in ways that affect the catalog
data.  This is true of DTML, user-defined ZClasses, or whatever.  In
particular, almost all changes to ZPT objects go through the write()
method, so causing that to kick the catalog will catch most (or possibly
all) cases.

Cheers,

Evan @ digicool