[Zope-dev] Length of Search Results/ZServer Crawling

Martijn Pieters mj@antraciet.nl
Tue, 21 Sep 1999 11:46:16 +0200


At 22:24 20/09/99 , Jason Spisak wrote:
>Zopsters,
>
>Does anyone know why this code:
>
>             <!--#in "Catalog(meta_type=['MyClass'])"-->
>              <!--#var "_.len(Catalog.searchResults())"-->
>             <!--#/in-->
>
>Outside the Catalog, renders the number of all the objects in the
>Catalog and not the Amount of MyClasse instances in the Catalog?
>I'd like to get the number of objects of a give type with some property
>values that are cataloged, but I'm unable to.

That's because Catalog() is the same as Catalog.searchResults(). So you 
could rewrite your code to:

   <dtml-in "Catalog(meta_type=['MyClass'])">
     <dtml-var "_.len(Catalog())">
   </dtml-in>

and then you'll see what you're doing wrong =).
Better use this:

   <dtml-in "Catalog(meta_type=['MyClass'])">
     <dtml-var "_.len(Catalog(meta_type=['MyClass']))">
   </dtml-in>

or you could use one of the count- variables to determine the number of 
objects:

   <dtml-in "Catalog(meta_type=['MyClass'])">
     <dtml-var count-meta_type>
   </dtml-in>

--
Martijn Pieters, Web Developer
| Antraciet http://www.antraciet.nl
| Tel: +31-35-7502100 Fax: +31-35-7502111
| mailto:mj@antraciet.nl http://www.antraciet.nl/~mj
| PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149
------------------------------------------