Howto use has_permission (was RE: [Zope] How to test for a user h aving a permission?)

Mayers, Philip J p.mayers@ic.ac.uk
Fri, 16 Mar 2001 14:37:25 -0000


Maybe I'm being dumb, but this doesn't work for me:

This doesn't work at all: <dtml-if
"AUTHENTICATED_USER.has_permission('View',subfolder)">
                          <dtml-if
"AUTHENTICATED_USER.has_permission('Access contents
information',subfolder)">

This always returns false: <dtml-if
"AUTHENTICATED_USER.has_permission('View','subfolder')">
                           <dtml-if
"AUTHENTICATED_USER.has_permission('Access contents
information','subfolder')">

How do I use this?

Regards,
Phil

+----------------------------------+
| Phil Mayers, Network Support     |
| Centre for Computing Services    |
| Imperial College                 |
+----------------------------------+  

-----Original Message-----
From: Hamish Lawson [mailto:hamish_lawson@yahoo.co.uk]
Sent: 15 March 2001 00:06
To: Dieter Maurer; Tim Cook
Cc: zope@zope.org
Subject: Re: [Zope] How to test for a user having a permission?


Tim Cook wrote:

> <dtml-if
> expr="AUTHENTICATED_USER.has_permission('Edit','PARENTS[0]')">
>   <a href="<dtml-var absolute_url>/manage_main">Edit</a>
> </dtml-if>
  
Thanks. Brian Lloyd also mentioned has_permission() in reply to my post
on the (mis)use of hasRole().

Dieter Maurer wrote: 

> Look in the embedded Online Help system -> API reference -> User

I'd already had a look in the online help, but there's no section for
User (at least in my Zope installation), and the section for
AuthenticatedUser doesn't list has_permission() - perhaps it ought to.
I will concede, though, that I could easily enough have done a grep
through the Zope source for the likely candidates, "def hasPermission"
or "def has_permission" <sheepish grin>.

Hamish Lawson


____________________________________________________________
Do You Yahoo!?
Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk
or your free @yahoo.ie address at http://mail.yahoo.ie

_______________________________________________
Zope maillist  -  Zope@zope.org
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )