[Zope-CMF] Question, re: folders w/ thousands of items

Jeffrey P Shell jeffrey@cuemedia.com
Thu, 08 Aug 2002 16:06:53 -0600


On 8/8/02 2:48 PM, "sean.upton@uniontrib.com" <sean.upton@uniontrib.com>
wrote:

> Hmm... perhaps there is either a bug or I'm doing something wrong, then, I
> think?  The following code still outputs results from an entire hierarchy of
> paths underneath, and changing the level to 1 causes results to be empty no
> matter what object context is referring to:
> 
> 
> path = context.getPhysicalPath()
> pathstr = ''
> for item in path:
>   pathstr = pathstr + '/' + item
> pathstr = pathstr[1:]  #pathstr ends up being something like
> '/CMFSite/SomeFolder'
> results = context.portal_catalog(path={'query':pathstr, 'level':0})[:10]
> 
> 
> I got started by looking at http://www.zopelabs.com/cookbook/1001898394, but
> this example doesn't really deal with level.  I'm interested in getting, for
> example, sibling items in a folder without getting items contained in
> siblings... Thoughts?

I've never understood that 'level' attribute, but I'm pretty sure it doesn't
do what you want.  Almost all other tree based storage systems with some
sort of Query language (WebDAV, LDAP, even Microsoft's Exchange 2000) have
the concept of "Depth Searching", usually with the options of 0 (match only
the specified object), 1 (search/match in the object and its immediate
children), and Infinite (go from this point in the tree onwards).

Catalog gives us 'infinite'.

The Zope Book's documentation for 'level' is a tad confusing, but I think I
now understand it to mean how deep in the Zope tree to start searching, or
to apply its match against (ie - you can apparently match the same path in
different parts of the tree) but not how far to keep searching.

http://www.zope.org/Documentation/ZopeBook/SearchingZCatalog.stx#3-99

I've thought about adding to PathIndex (or creating my own subclass) to do
depth based searching, but I've never been able to make the time.  :/.

Depth based searching would do what you want, and I think it would be
infinitely useful - more than the cryptic 'level'.

So, to list all the Documents in the current folder, one could do the
following (in my dreams):

 here.portal_catalog(type='Document',
                     path={ 'query':'/'.join(here.getPhysicalPath()),
                            'depth': 1 }
                    )

-- 
Jeffrey P Shell 
www.cuemedia.com