[Zope] CatalogAware does not work?

John Morton jwm@plain.co.nz
Thu, 19 Apr 2001 11:17:35 +1200


On Thursday 19 April 2001 04:36, Casey Duncan wrote:
>  Milos Prudek wrote:
>  > I followed Automatic Cataloging example in Zope Book, Chapter 9.
>  >
>  > Everything works fine except automatic cataloging of newly created
>  > fields ("author", "content"). When I change data in those  fields it=
 is
>  > not reflected in the catalog.

>  CatalogAware does not update things when properties are changed. This
>  can be solved by intercepting manage_editProperties and
>  manage_changeProperties, but I'm not sure if this is practical in a
>  ZClass.

To ensure your instance gets reindexed when the properties change, you
need to have the method that processes the property change form call the
reindexing method after you commit the changes, just like you do when add=
ing=20
the instance.

>  Why couldn't CatalogAware do this? If nobody has a good reason, I migh=
t
>  push forth a patch to CatalogAware to implement this.

A simple case for the present flexibility is that you don't need to reind=
ex=20
for every property change, just the ones that are actually indexed.

A more complicated case would be an operation that changes several instan=
ces=20
at once. It's expensive to reindex for every instance you change, so it w=
ould=20
be useful to pass a flag to the ZClass's change method to tell it not to =
do a=20
reindex, and reindex the lot once the operation over all the instances is=
=20
completed.

I guess that you could build this kind of functionality into CatalogAware=
,=20
but I'm generally in favour of having flexible and optional rather than=20
automatic reindexing, and just adding documentation to discuss some of th=
e=20
different cases.=20

You could hack Property Sheet Interface to add a call to reindex if the=20
ZClass is catalog aware.

John