Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8870899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:51:01+00:00 2026-06-14T17:51:01+00:00

I thought this must be easy but I really have troubles figuring it out:

  • 0

I thought this must be easy but I really have troubles figuring it out: I’d like to check for an acquired permission of a role on an object.

I don’t want to check for the actual user’s roles or permissions, I just want to check i.e. if on an object Anonymous has the permission ‘Access contents information’. This is easy if the permission is set on the object in question, but proves more difficult when the permission is acquired.

I tried this:

siteRoles = ('Anonymous', 'myRole1', 'myRole2', 'Manager')
permission = 'Access contents information'

rolesDictList = self.rolesOfPermission( permission )

roles = [roleDict['name'] for roleDict in rolesDictList if roleDict['selected']]

for i, role in enumerate(siteRoles):
    if role in roles:
        roleMin = i
        break

return roleMin

This does not work, because it does not give the acquired permissions.

My next idea was to walk through the parents upward until I find some permissions that are not acquired. But this would not really solve the problem, as it would ignore permissions that are set higher up in the hierarchy (ok, I could check for acquired and continue upward). Also there is an oddity: ‘Manager’ is always selected in rolesOfPermission. Why is this so?

Anyway, I presume there must be a simpler way to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:51:02+00:00Added an answer on June 14, 2026 at 5:51 pm

    Simply use the rolesForPermissionOn() function:

    from AccessControl.PermissionRole import rolesForPermissionOn
    
    roles = rolesForPermissionOn(permission, context)
    

    This returns a list of roles that have the specific permission for the given context. It’ll walk the acquisition chain as needed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I realise this must be a really easy piece of regex, but just can't
I thought this would be fairly simple but it turns out not to work
I thought this would be fairly easy, but I'm totally baffled. I want one
I thought this would be pretty easy but I'm running into all sorts of
I thought this question would have already existed on SO, but then I couldn't
I thought this was covered elsewhere but I don't see it now. Anyway, having
I thought this would be very easy. I downloaded the JDK, extracted src.zip, modified
I thought this was a privilege issue but I logged on as admin and
I thought this would be easy. The Google makes me think otherwise. What I
This goes back to my other question which I thought was sufficiently answers but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.