[Zope] External Method 3

Rik Hoekstra rik.hoekstra@inghist.nl
Thu, 30 Mar 2000 21:41:06 +0200


-----Original Message-----
From: Tom Deprez <tom.deprez@uz.kuleuven.ac.be>
To: Rik Hoekstra <rik.hoekstra@inghist.nl>
Date: donderdag 30 maart 2000 16:14
Subject: Re: [Zope] External Method 3


>Hi Rik,
>
>>I was blabbering last time about hasattr. The right solution is of course:
>>
>>def recursiveMethod(self, obj, result):
>>     if hasattr(obj, aq_parent):
>>            result.append(obj.title)
>>            recursiveMethod(self, obj.aq_parent, result)
>>     return result
>
>mmm, what does hasattr()? Does it checks if an obj as a certain property
>(eg aq_parent)?

yes, only in pythonish these are called attributes.

>Unfortunately it seems not to work.

Hm, I tested it. It works for me. Can you tell me where it doesn't work and
in what way? Does it fail. Is there a traceback? Remember it will still bail
out (with an AttributeError) if the object has no attribute title!

>
>I found another way to check if it has parents :
>
>split(obj.absolute_url(),'/')[3:-1] != []
>
>--> this works, but I think your solution is nicer, only it should work and
>I don't know why it doesn't.


any more details?

Rik