[Zope] getPhysicalRoot() method

Max M maxm@mxm.dk
Wed, 26 Jun 2002 14:35:56 +0200


Nico de Boer wrote:

>I want to get the QUERY_STRING, so I can use it for my <dtml-with>
>loop. I heard from Max that you can traverse Zope with a path from code 
>directly. You have to use the restrictedTraverse() method..
>
>But the getPhysicalRoot() method gives me a NameError:
>
>NameError: global name 'getPhysicalRoot' is not defined
>

It's a secutiry problem. From the docs:

"getPhysicalRoot()
Returns the top-level Zope Application object.
Permission: Python only"


So you need to write an external method which does it for you.

def getObjByPath(self, path):
    return self.getPhysicalRoot().restrictedTraverse(path)

regards Max M

-- 

"Sorry I would Really Like To Help More On This Project,
But Am To Busy Doing Paid Work On A Tight Deadline"
    Max M