[Zope] How to access Zope root in Script (Python)
Oliver Bleutgen
myzope@gmx.net
Thu, 28 Nov 2002 17:12:21 +0100
Clemens Robbenhaar wrote:
> Hi Jon,
>
> > How do I refer to the root Zope directory within a Python script?
>
> From file system level code one could just say "context.getPhysicalRoot()",
> but for some reason this is not allowed inside a Script. Maybe this is
> due to security restrictions this people cannot mess with the Zope root
> if they do only have permissions for some nested folders.
>
> You could try:
>
> 1. use an External Method as a helper, which calls getPhysicalRoot()
> on the file system level.
>
> 2. use 'restrictedTraverse':
>
> root = container.restrictedTraverse('/')
>
> The second one is possibly the simpler way to do it.
And it doesn't work, because restrictedTraverse traverses the path down
from the ObjectManager it's called on, i.e. its argument is the path
relative to container in your example.
cheers,
oliver