[Zope-dev] 2.3.x Catalog Brains

Casey Duncan cduncan@kaivo.com
Tue, 20 Mar 2001 16:03:08 -0700


In doing some development using Catalogs in 2.3.x, I have run across
some interoperability bugs between the various Catalog classes.

1. Catalog brains are slightly broken when applied agains plain
Catalogs. Looking at __getitem__ in Catalog.py (line 225 and 231 in
2.3.1b2 in particular), the result record is made into a brain which is
an aquisition wrapper of the parent of the Catalog object.

When using a ZCatalog this is fine because the ZCatalog is the parent of
the Catalog. However, when a Catalog is used alone the getPath, getURL,
getObject, etc. methods of the brain do not work because they expect to
find a getpath method which only exists in ZCatalog. Since this is
merely a lookup into the Catalog's paths dictionary, I see no reason why
this getpath method can't be in Catalog. 

A patch will be needed for Catalog.py and CatalogBrains.py to accomplish
this, and I would be happy to provide one. However, I need to know why
exactly the brains are wrappers of the Catalog's parent rather than the
Catalog itself. Is this a security issue of some kind?

Another fix for this would be to use slightly different brains for
Catalogs vs. ZCatalogs. From what I see the mechanism for this is
already in place.

2. This one is less of a bug than a feature request. I have created a
CatalogPlus class that basically enhances the Catalog so that is plays
well with CatalogAware. This entails just adding the catalog_object and
uncatalog_object methods from ZCatalog to Catalog. It would seem to me
to be quite easy to modify Catalog or CatalogAware to account for this
automatically. Also why are subtransactions part of ZCatalog and not
Catalog? My guess is that it is a ZODB specific feature so it doesn't
belong in Catalog, is that right?
-- 
| Casey Duncan
| Kaivo, Inc.
| cduncan@kaivo.com
`------------------>