RE: [Zope] has_permission
Hi everybody!
I still cannot make has_permission to work. What I want to do is check whether a file X has permission Y.
In this example, I want to see if the file X, containing this code, is viewable by the user. What I have been told I should do (thanks!) is using AUTHENTICATED_USER.has_permission, but I don't know what arguments I should pass. One is the permission, e.g. 'View', and the other one should be the file I guess, but how? None of my guesses work. Let's say the file is called 'test', why can't I do:
<!--#if "AUTHENTICATED_USER.has_permission('View', test)"--> nor <!--#if "AUTHENTICATED_USER.has_permission('View', self)"--> ????????
Any help would be highly appreciated.
Floyd
Assuming that this code is actually _in_ the 'test' document, you should be able to use: <!--#if "AUTHENTICATED_USER.has_permission('View', this())"--> Brian Lloyd brian@digicool.com Software Engineer 540.371.6909 Digital Creations http://www.digicool.com
Hi Brian and everybody else! <!--#if "AUTHENTICATED_USER.has_permission('View', this())"--> This isn't working. Any more suggestions, PLEASE!!!! Thank you, Floyd Brian Lloyd wrote:
Hi everybody!
I still cannot make has_permission to work. What I want to do is check whether a file X has permission Y.
In this example, I want to see if the file X, containing this code, is viewable by the user. What I have been told I should do (thanks!) is using AUTHENTICATED_USER.has_permission, but I don't know what arguments I should pass. One is the permission, e.g. 'View', and the other one should be the file I guess, but how? None of my guesses work. Let's say the file is called 'test', why can't I do:
<!--#if "AUTHENTICATED_USER.has_permission('View', test)"--> nor <!--#if "AUTHENTICATED_USER.has_permission('View', self)"--> ????????
Any help would be highly appreciated.
Floyd
Assuming that this code is actually _in_ the 'test' document, you should be able to use:
<!--#if "AUTHENTICATED_USER.has_permission('View', this())"-->
Brian Lloyd brian@digicool.com Software Engineer 540.371.6909 Digital Creations http://www.digicool.com
At 06:55 PM 8/5/99 +0200, Florian Mueller wrote:
<!--#if "AUTHENTICATED_USER.has_permission('View', this())"-->
This isn't working.
Florian, we need more information to understand what you want and how the above is not fulfilling it. Looking at your previous emails it seems that you want to test if a user has a permissions on an object. As of Zope 2, you can use the 'has_permission' method of a user object. The arguments it takes are a permission name, and an object. Brian suggested using 'this()' to grab the object in the case where your DTML is in a method which is acquired by the object. If this is not the case, you need to specify the object explicitly, <!--#if "AUTHENTICATED_USER.has_permission('View',myObject)"--> If this isn't working for you, please explain what you expect to happen and in what way it is failing, including what version of Zope you are using, how you have your DTML and object setup and any tracebacks. Good luck! -Amos
participants (3)
-
Amos Latteier -
Brian Lloyd -
Florian Mueller