[Zope] restrictedTraverse doesn't give the good container

Dieter Maurer dieter at handshake.de
Mon Feb 9 13:42:21 EST 2004


Pascal Samuzeau wrote at 2004-2-9 15:15 +0100:
> ...
>Now I just delete the last FolderC, I have:                           
>                                                                      
>- FolderA                                                             
>---FolderB                                                            
>----FolderC                                                           
>                                                                      
>I try :                                                               
>                                                                      
>herenow = context.restrictedTraverse(path+'/FolderC')  -> OK          
>herenow = herenow.restrictedTraverse(path+'/FolderC')  -> OK          
>                                                                      
>BUT here I'm just not where I think to be, just because of the        
>acquisition !!!                                                       
>                                                                      
>I have no time to have a look on this,

Interesting that you report a problem you have no time for....

>but anyone have seen this      
>problem and resolved it?                                              

This is normal acquisition behaviour...

Modern Zope versions make "aq_inner" available to TTW code.
With such versions, you can use "hasattr(obj.aq_inner.aq_explicit, XXX)"
to check whether "obj" has an unaquired attribute "XXX".

There is also my "hasattr_unacquired" path that provides
"hasattr_unacquired". Its effect is identical to the above
"aq_inner.aq_explicit" magic but it is easier to understand
(for non experts)...

-- 
Dieter



More information about the Zope mailing list