faqts : Computers : Internet : Web Servers : Zope : Common Problems

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

7 of 11 people (64%) answered Yes
Recently 4 of 8 people (50%) answered Yes

Entry

How do I count the 'children' of any one onject?

Aug 9th, 2000 06:15
unknown unknown, Kapil Thangavelu


if children aren't nested
<dtml-let x="objectIds(['childrenClass'])">
<dtml-var "_.len(x)">
</dtml-let>
if children are nested you probably need a recursive dtml/python method.
in python 
def count_children(o):
        x = o.objectItems(['childClass'])       
        sum = len(x)
        for child, child_name in x:
                sum = sum + count_children(child)
        return sum