[Zope] How to access Zope root in Script (Python)

Oliver Bleutgen myzope@gmx.net
Fri, 29 Nov 2002 15:51:47 +0100


Chris Withers wrote:
> Oliver Bleutgen wrote:
> 
>>>
>>> Oh yes it does, works fine for me in Zope 2.6.
>>>
>>> In OFS/Traversable.py line 95 the it calls getPhysicalRoot() if the path
>>> starts with a '/'.
>>
>>
>> Oh, sorry then, this must have got changed in some zope version. Ok, I 
>> learned something.
> 
> 
> Nope, it's always worked like that ;-)
> 

Dang,
you're right, it also works in Zope 2.3.3 - well sort of, 
restrictedTraverse('/') gives an error about "string index out of range" 
in Traversable.py. Guess noone is interested in a bug report for 2.3.3 ;-).

But maybe the online help should be fixed, atleast I was misguided since 
I first learned about restrictedTraverse:

"""Return the object obtained by traversing the given path from the 
object on which the method was called, performing security checks along 
the way.

If an object is not found then the default argument will be returned."""

I don't have 2.6, if someone can tell me if the text there is the same, 
I might put up something in the collector for a small cosmetic fix.

cheers,
oliver