Good day all, Using Zope 2.7.6 I'm trying to use the getPhysicalRoot() function. In a rather large site we have a folder called 'functions' placed in root. This folder contains a formatting function 'far' I want to use in some other folder. But in the path from root to the place I the function to be called, I have another 'function' folder, with local functionality. When calling 'context.functions.far()', it fails to acquire the far function. Which is explainable. My plan was to call it directly: 'root.functions.far()', but 'root' does not exist in the zope (python) script. if I use root = context.getPhysicalRoot() I am forced to reenter my Zope username and password and will not get permission to call the getPhysicalRoot function. What am I doing wrong? What can I do to make the getPhysicalRoot function available? Friendly greetings, Robert-Reinder Nederhoed The Hague, The Netherlands --
--On 28. Juli 2005 13:24:37 +0200 rr@nederhoed.com wrote:
Good day all,
Using Zope 2.7.6 I'm trying to use the getPhysicalRoot() function.
In a rather large site we have a folder called 'functions' placed in root. This folder contains a formatting function 'far' I want to use in some other folder. But in the path from root to the place I the function to be called, I have another 'function' folder, with local functionality.
When calling 'context.functions.far()', it fails to acquire the far function. Which is explainable.
My plan was to call it directly: 'root.functions.far()', but 'root' does not exist in the zope (python) script.
if I use root = context.getPhysicalRoot()
I am forced to reenter my Zope username and password and will not get permission to call the getPhysicalRoot function.
What am I doing wrong? What can I do to make the getPhysicalRoot function available?
Looks like the method is restricted. VerboseSecurity will tell you why. -aj
rr@nederhoed.com wrote at 2005-7-28 13:24 +0200:
... if I use root = context.getPhysicalRoot()
I am forced to reenter my Zope username and password and will not get permission to call the getPhysicalRoot function.
What am I doing wrong?
For unknown reasons, "getPhysicalRoot" is private. The standard workaround looks like this: root = container.restrictedTraverse('/') Of course, it is stupid to make "getPhysicalRoot" private when it is so easy to access the root anyway... -- Dieter
Solved. Thanks for the reactions. It works! My current code looks like this now: #force function in '/root/functions' far = context.restrictedTraverse('/').functions.far x = foo() print far(value=x)
Of course, it is stupid to make "getPhysicalRoot" private when it is so easy to access the root anyway... Why not just add 'root' to the script vocabulary?
Friendly greetings from an almost nightly The Hague, Robert-Reinder --
Robert-Reinder Nederhoed wrote:
Solved.
Thanks for the reactions. It works! My current code looks like this now:
#force function in '/root/functions' far = context.restrictedTraverse('/').functions.far
x = foo() print far(value=x)
Of course, it is stupid to make "getPhysicalRoot" private when it is so easy to access the root anyway...
Why not just add 'root' to the script vocabulary?
If I recall, Casey Duncan suggested putting a python script in *root* named ROOT, e.g. #module ROOT return container This is aquirable from anywhere else in Zope and is easy to remember. David
Please file a bug report to make getPhysicalPath() publilc. I agree with Dieter that it is dumb to make it private if you can get the root using restrictedTraverse()). -aj --On 28. Juli 2005 22:22:42 +0200 Robert-Reinder Nederhoed <rr@nederhoed.com> wrote:
Solved.
Thanks for the reactions. It works! My current code looks like this now:
# force function in '/root/functions' far = context.restrictedTraverse('/').functions.far
x = foo() print far(value=x)
Of course, it is stupid to make "getPhysicalRoot" private when it is so easy to access the root anyway... Why not just add 'root' to the script vocabulary?
Friendly greetings from an almost nightly The Hague, Robert-Reinder
-- _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Robert-Reinder Nederhoed wrote at 2005-7-28 22:22 +0200:
...
Of course, it is stupid to make "getPhysicalRoot" private when it is so easy to access the root anyway... Why not just add 'root' to the script vocabulary?
If I would want to increase the script vocabulary, I would add "request". "root" is very rarely used... -- Dieter
On 7/29/05, Dieter Maurer <dieter@handshake.de> wrote:
Robert-Reinder Nederhoed wrote at 2005-7-28 22:22 +0200:
...
Of course, it is stupid to make "getPhysicalRoot" private when it is so easy to access the root anyway... Why not just add 'root' to the script vocabulary?
If I would want to increase the script vocabulary, I would add "request".
"root" is very rarely used...
+1 (if this ever becomes a vote) The PageTemplates and Python Scripts should meet somewhere and become more identical in how their zope magic works. Just!! for the sake of not confusing beginners.
-- Dieter _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
-- Peter Bengtsson, work www.fry-it.com home www.peterbe.com hobby www.issuetrackerproduct.com
participants (6)
-
Andreas Jung -
David H -
Dieter Maurer -
Peter Bengtsson -
Robert-Reinder Nederhoed -
rr@nederhoed.com