[Zope-CMF] Query portal_catalog for current object?

Jon Edwards jon@pcgs.freeserve.co.uk
Mon, 28 Jan 2002 11:31:05 -0000


Thanks for the feedback Seb,

I'm trying to store some "metadata" for every object in the portal
(including folders), to enable my navigation/organisation widgets to do
their stuff. But I'm trying to avoid sub-classing/changing existing types,
so that my add-ons can be used with any new/existing CMF products, without
hacking/subclassing all the products. So, I thought I'd subclass the catalog
to store that metadata, then all my changes are in one place, for ease of
implementation/upgrading

I've got 4 properties -

org_id - (like your "Site" property)
org_type - (eg. 'hospital', 'chemist', 'GP')
menu_text - (in case the title is too long for the menu)
menu_sortorder - (for sorting the menu :-)

The first 2 are dynamically generated by a Pythonscript (sub-classing the
catalog, like your how-to, has the advantage that they'll be recalculated if
an object is moved, by the reindexObject). The second 2 are entered by the
user, which is why I need to be able to get them into a form for editing.
There might be a better way to store the second 2, but lumping them all
together in the catalog seemed the simplest! :-)

>   item_brain = portal_catalog(id=this_id)

Would this still work if you had an object in a different part of the site
with the same id? (eg. if you had copied an object from one folder to
another)

Cheers, Jon