[Zope-CMF] Query portal_catalog for current object?
Jeffrey P Shell
jeffrey@cuemedia.com
Mon, 28 Jan 2002 14:00:28 -0700
On 1/28/02 1:03 PM, "Dieter Maurer" <dieter@handshake.de> wrote:
> Jon Edwards writes:
>> 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
> You may use a "Path" index, provided it works now.
>
> In earlier Zope versions, the "Path" was always catalogued as "None".
The path works now, although there's no 'depth' limiting like LDAP and
WebDAV have. So, you better hope that there's no objects with the same 'id'
value below your point in the path.
Anyways, a query might look like:
here.portal_catalog(path='/'.join(here.getPhysicalPath()),
id=here.getId())
But this might fail if you have a hierarchy like this:
/foo/about
/foo/bar/about
And the 'here' in question is 'foo/about'.
It would be so very very very nice if you could do this:
here.portal_catalog(path={'query': '/'.join(here.getPhysicalPath()),
'depth': 1},
id=here.getId()
)
--
Jeffrey P Shell
www.cuemedia.com
Sent using the Entourage X Test Drive.