[Zope] checking permissions

A M Thomas am@virtueofthesmall.com
Sun, 28 Apr 2002 23:00:51 -0400


Hi there,

I'm trying to make my own management view links, and can't find the
correct way to test for whether a method can be used by the current user
based on just the method name.  Here's a section of my python code:

===================================
from AccessControl import getSecurityManager
checkPermission = getSecurityManager().checkPermission

manage_options=context.filtered_manage_options()

optionslist = []

for mopt in manage_options:
  print "<br>checking", context.url() + '/' + mopt['action']
  if  checkPermission(mopt['action'], context):
    optionslist.append([mopt['action'], mopt['label']])
===================================

Basically, when I'm logged in as "manager", every method in
manage_options checks out.  However, when I log in as another user -
which user does in fact have access to the appropriate methods - the
checkPermission test fails.  I'm pretty sure I should be supplying a
permission name as the first argument to checkPermission, rather than
the method name, but is there a way to test based just on the method
name?  I can get a handy list of methods using the
filtered_manage_options method, but not permissions, as far as I can
tell (and no, they're not already tested, as far as I can tell - my test
user gets a tab to manage security settings, but can't get a page by
clicking on it).

Thanks in advance for any help - I appreciate it very much :)

- Am