[Zope] External Method

Phil Harris phil.harris@zope.co.uk
Tue, 28 Mar 2000 13:54:23 +0100


Tom,

How about something like (untested):

def GetParentNames(self):
    p=self.REQUEST.PARENTS[:]
    result=[]
    for obj in p:
           if obj.meta_type =='KBItem':
                result.append(obj.Title)
    return result

HTH

Phil
phil.harris@zope.co.uk


----- Original Message -----
From: "Tom Deprez" <tom.deprez@uz.kuleuven.ac.be>
To: <zope@zope.org>
Sent: Tuesday, March 28, 2000 1:28 PM
Subject: [Zope] External Method


> I want to make an external method which does the following :
>
> iterates over all the parents, if a parent is of a certain type, the title
> must be added to a list. However I don't know how to iterate over an
object
> (ZClass) it's parents in Python/Zope. Can anybody help?
>
> def GetParentNames(self):
>   obj=self
>   result=[]
>   while obj.parent<>nil: <-- this is wrong
>     obj=obj.parent <-- this is wrong
>     if obj.meta_type=='KBItem':
>       result.append(obj.Title)
>   return result
>
> Thanks in advance,
>
> Tom.
>
> _______________________________________________
> 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 )