[Zope-dev] ZCatalog brains

Steve Alexander steve@cat-box.net
Thu, 10 Aug 2000 10:24:14 +0100


Chris Withers wrote:
> 
> Steve Alexander wrote:
> > Is there any good reason that the "brains" returned by ZCatalog searches
> > don't have a standard property that reflects the URL of the object they
> > have meta-data from?
> 
> That sounds like a good idea :-)
> 
> > This would seem to me to be more object-oriented, and would save calls
> > to someCatalog.getpath(data_record_id_) in loops.
> 
> All you'd need to do is find some way of returning this from a method of
> your object-being-catalogued that takes no arguments and then you could
> add it as normal meta-data column.
> 
> I wonder if that's possible?

Yes. The url method of CatalogAwareness does this. So you could just add
"url" to the metadata of your catalog.

> cheers,
> 
> Chris
> 
> PS: You could always just make your own brains that returned the results
> of this call, but that doesn't make it any more efficient :(

It makes it less efficient, as the object would have to be obtained when
you made the brain.url call. Not much point using brains at all then.


Although there are ways to do this now, I guess I was wondering about
making it a standard part of catalogs.

Thinking further though, if it is as easy as adding "url" to the
catalog's metadata, why bother?

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net