[Zope] manage_access: show permissions for a user

Amos Latteier amos@aracnet.com
Thu, 29 Jul 1999 13:13:38 -0700


At 09:44 PM 7/29/99 +0200, Florian Mueller wrote:
>Unfortunately, I do not have telnet access to the zope installation, so
>I cannot look it up the way you suggested. So once again,
>how can I check in DTML if user X has permission Y to access file Z?
>
>In my opinion, it should be something like:
><!--#call show_permission('View', 'Manager') -->
>but this call does not exist, and with
>manage_permission
>I can only change permissions, but not display them.

I believe that this came up on the list a little while ago.

Take a look at OFS.AccessControl.User.has_permission and User.has_role

    def has_permission(self, permission, object):
        """Check to see if a user has a given permission on an object."""
        
    def has_role(self, roles, object=None):
        """Check to see if a user has a given role or roles."""

Here's an example,

<!--#if "AUTHENTICATED_USER.has_permission(myFile,'View')"-->
<a href="./myFile">View the file</a>
<!--#else-->
You are not authorized to see the file.
<!--#/if-->

-Amos