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 adding the instance.
Why couldn't CatalogAware do this? If nobody has a good reason, I might push forth a patch to CatalogAware to implement this.
A simple case for the present flexibility is that you don't need to reindex for every property change, just the ones that are actually indexed. A more complicated case would be an operation that changes several instances at once. It's expensive to reindex for every instance you change, so it would be useful to pass a flag to the ZClass's change method to tell it not to do a reindex, and reindex the lot once the operation over all the instances is completed. I guess that you could build this kind of functionality into CatalogAware, but I'm generally in favour of having flexible and optional rather than automatic reindexing, and just adding documentation to discuss some of the different cases. You could hack Property Sheet Interface to add a call to reindex if the ZClass is catalog aware. John