[Zope] getting the number of returned objects

Timothy Wilson wilson@visi.com
Sat, 20 Oct 2001 14:25:30 -0500 (CDT)

On Sat, 20 Oct 2001, Chris McDonough wrote:

> Getting the number of results returned by a Catalog query is a thing 
> that folks commonly want to do, and usually just doing len(resultset) 
> works OK.  I'm surprised it didn't for you.
> That said, it's an extremely expensive operation under some 
> circumstances because it un-lazifies the carefully-lazified Catalog 
> resultset, creating a brain object for each matching catalog record.  If 
> there's a way to not do this in your application, I'd recommend it.

Thanks for the quick reply. The cost of this particular operation isn't
really important since this method will only get called once per day. (I'm
trying to set up a method that will email the next day's school lunch menus
to a listserv *if* there is a lunch menu for tomorrow.)

I know it works to make two scripts, the first Python Script simply does the
Catalog query and returns true if the query returned anything, and the
second DTML Method just does the query again if the result of calling the
first Python Script was "true" and processes the results.


Tim Wilson      |   Visit Sibley online:   | Check out:
Henry Sibley HS |  http://www.isd197.org   | http://www.zope.com
W. St. Paul, MN |                          | http://slashdot.org
wilson@visi.com |  <dtml-var pithy_quote>  | http://linux.com