[Zope] Preventing duplicates in ZCatalog

Dieter Maurer dieter@handshake.de
Tue, 22 Apr 2003 21:27:48 +0200


Wankyu Choi wrote at 2003-4-22 18:51 +0900:
 > I have a very evasive problem again ;-) with ZCatalog. I'm very sorry if
 > this topic has been dealt with; I couldn't find any info on this one.
 > 
 > Here's a very simple concept I'd like to implement in my applications using
 > ZCatalog:
 > 
 > 	** Every entry in the built-in ZCatalog should be unique.  No
 > duplicates!**
 > 
 > However, every object's reference could get duplicated ( that is, inserted
 > more than once ) when the object is accessed via acquisition. Say, when I
 > have two folders, *dir1*, *dir2" and an object "obj1" in the dir1 folder:
 > 
 > 	* Accessing obj1 via /dir1/obj1 catalogs it with the uid
 > "/dir1/obj1".
 > 
 > 	* Accessing it again via "/dir1/obj1", skips catalogging the object
 > or recatalog it with the same uid.
 > 
 > 	* Accessing it via "/dir2/obj1" or "/dir2/dir1/obj1" duplicates the
 > catalog entry with with a different uid.

Modern Zope releases uses "getPhysicalPath" as "uid" for
the catalog. "getPhysicalPath" is independant from the
access path (up to hacks).

When you see the same object catalogued under different catalog
uids, you should either upgrade to Zope 2.6.1
or fix the code that does not use "getPhysicalPath".
A likely candidate it "Products.ZCatalog.CatalogAware".
Replace this by "Products.ZCatalog.CatalogPathAware".


Dieter