[Zope-CMF] Query portal_catalog for current object?

seb bacon seb@jamkit.com
28 Jan 2002 10:38:24 +0000


Can the values be computed attributes of the content type itself (for
example, pythonscript methods on the ZClass)?  That's the best way of
doing it - then you just add the name of that attribute to the catalog
index for it to be catalogued.

Otherwise, to answer your question, you'd have to get a record from the
catalog like 

  item_brain = portal_catalog(id=this_id)

Then if the property you're after is part of the metadata for the index
you can just go

  item_brain.property

Or if it's not, you can get the object itself like:

  ob = item_brain.getObject()

seb

On Mon, 2002-01-28 at 01:08, Jon Edwards wrote:
> This may be a simple question, but I've hunted around and can't find any
> docs that cover it :-)
> 
> Is it possible to query the portal_catalog to find info on a specific
> object, when you are viewing/editing that object? Something like -
> here.portal_catalog(this_item_id).Site
> 
> I want to store some dynamically-generated values in the catalog - a bit
> like Seb's example of Subclassing the catalog-tool -
> http://cmf.zope.org/Members/seb/CreateCatalogTool/view - where the "Site"
> property is generated dynamically by a Pythonscript when the object is
> indexed. But then I want to be able to access the property in View/Edit
> pages for an object.
> 
> Hope that makes sense?
> 
> Cheers, Jon
> 
> 
> _______________________________________________
> Zope-CMF maillist  -  Zope-CMF@zope.org
> http://lists.zope.org/mailman/listinfo/zope-cmf
> 
> See http://www.zope.org/Products/PTK/Tracker for bug reports and feature requests