[Zope] Search ZCatalog from Python code

Max M maxm@mxm.dk
Thu, 13 Jun 2002 11:03:37 +0200

Ioannis Koukos wrote:

> I've been trying to find documentation on how to search the ZCatalog 
> from within a Zope product but there is a lack of documentation on 
> that. Can this be done? If this is the case, how can external python 
> products 'see' the context and container objects?

It could look something like::

    def doSearch(self, REQUEST=None, **kw)
        result = []
        for resultItem in self.Catalog(REQUEST, **kw) # call object as a function!
        return result
    # get Folders
    for folder in doSearch(meta_type='Folder')
        print folder.title_or_id()
But this "awakens" all the objects and can be an expensive way of doing it. Modify for your own amusement. Look in the Zope Books API reference for more info.

regards Max M

"Sorry I would Really Like To Help More On This Project,
But Am To Busy Doing Paid Work On A Tight Deadline"
    Max M