[Zope] manage_access: show permissions for a user
Florian Mueller
floyd@va.com.au
Mon, 02 Aug 1999 12:51:35 +0200
Thanks for the hint!
I got the .has_role to work, but the
AUTHENTICATED_USER.has_permission(myFile,'View') is not working for me:
I think I have to write
('View',myFile)
but still, I have no clue what to replace myFile with.
I want to check the permission of the actual file, i.e. the file which
contains this code,
and also the permission settings of the folder containing this file.
Any help would be highly appreciated.
Cheers,
Floyd
Amos Latteier wrote:
> 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
--
http://floyd.va.com.au