Some days ago we was experienced a strange behavior that I think could be useuful to share, and have some suggestions by others.
This is the story semplified: suppose to have a Catalog’s index named “foo” and to have a folderish content named “bar” that not implements an indexer “foo” nor has an attribute “foo”.
Suppose to add into “bar” another content and naming that content “foo”.
Now, whenever “bar” will be reindexed, the Catalog, during “foo” (the index) indexing, will found a “foo” attribute (the other content) callable (the default view of “foo”). So the Catalog will call the default view of the content “foo” thinking that as the index “foo” of “bar”…
This is not only an obvious wrong index data, but also a big penality in term of performances (calling the view could be very expensive).
There are a lot of other variants for this story, with Catalog’s metadata instead of index, or acquisition instead of direct containment, …
Personally I don’t have a simple solution for that, I think that probably catalog don’t ever need to getattr another object during indexing.
My “quick and dirty” solution for now wll be to monkeypatching Catalog’s safe_call function (https://github.com/zopefoundation/Products.ZCatalog/blob/3.0.x/src/Products/ZCatalog/Catalog.py#L43) to return as unsafe the default view of a content, but I think someone here could have a better solution.
Any hints or comments?