How can I count the results of a ZCatalog query? This must be a simple thing... I have tried <dtml-var "_.len(Catalog)"> but with no success. Juergen
Why do you expect that your approach gives you the number of results of a query when you don't specify the query? ;-) Try <dtml-var "_.len(Catalog(field1=...,field2=...))"> -aj ----- Original Message ----- From: "Juergen R. Plasser / Hexagon" <plasser@hexagon.at> To: <zope@zope.org> Sent: Friday, June 14, 2002 06:26 Subject: [Zope] Count results of ZCatalog query
How can I count the results of a ZCatalog query? This must be a simple thing...
I have tried <dtml-var "_.len(Catalog)"> but with no success.
Juergen
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
I am having a form based search here and the results page starts like <dtml-in Catalog size=20 start=query_start>, so I thought I could easily determine the length of "Catalog". I have tried <dtml-var "_.len(Catalog(REQUEST))"> and it seems to work ;-) Juergen --On Freitag, 14. Juni 2002 06:39 -0400 Andreas Jung <andreas@andreas-jung.com> wrote:
Why do you expect that your approach gives you the number of results of a query when you don't specify the query? ;-)
Try <dtml-var "_.len(Catalog(field1=...,field2=...))">
-aj
Juergen R. Plasser / Hexagon wrote:
I am having a form based search here and the results page starts like <dtml-in Catalog size=20 start=query_start>, so I thought I could easily determine the length of "Catalog".
I have tried <dtml-var "_.len(Catalog(REQUEST))"> and it seems to work ;-)
That's in fact the same approach as Andres is proposing. Tha Catalog take both a mapping object (dict like REQUEST), and/or keyword parameters. 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
Juergen R. Plasser / Hexagon wrote:
How can I count the results of a ZCatalog query? This must be a simple thing...
I have tried <dtml-var "_.len(Catalog)"> but with no success.
The "Catalog" you are refering to is an object not a function that returns a result. You can however call it as a function:: <dtml-call "Catalog(meta_type='Folder')"> and it will return a list of results. You can then take the len() of this list. <dtml-call "REQUEST.set('searchResult', Catalog(meta_type='Folder'))"> <dtml-var "_.len(searchResult)"> <dtml-in searchResult> ... etc. </dtml-in> 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
participants (3)
-
Andreas Jung -
Juergen R. Plasser / Hexagon -
Max M