[Zope-CMF] Re: How to count the number of replies?
Tres Seaver
tseaver@palladion.com
Mon, 30 Jul 2001 14:06:06 -0400
Ausum wrote:
> Thanks Tres.
>
> This is the code I came up with, to count the number of replies from an
> object, listed at a typical portal_catalog list:
>
> <dtml-with getObject>
> <dtml-if talkback>
> <dtml-let hasReplies="talkback.hasReplies( this() )">
> <dtml-if hasReplies>
> <dtml-var "talkback.replyCount( this() )">
> </dtml-if>
> </dtml-let>
> </dtml-if>
> </dtml-with>
>
> Put in a method it works fine, but I'm supposing that due it has to call
> every found object in order to tell whether it has replies or not, it is
> somehow costly. Shouldn't 'num_of_replies' be a catalogable object's
> property, updated by the workflow? How do I perform this?
Add a metadata column to the catalog, 'num_of_replies', which will be
recomputed each time a content object is catalogued. You can then
use it in a catalog-driven page without the 'getObject' bit, which is
what is causing the expense.
Tres.
--
===============================================================
Tres Seaver tseaver@zope.com
Zope Corporation "Zope Dealers" http://www.zope.com