Over a million developers have joined DZone.

Check That A User Has Permission On All Parents In Zope

If you need to be sure that a user can view an object, you need to check the View permission not only on the object but also all of its parents.  To do this, I slightly modified the script at http://zopelabs.com/cookbook/1018022911 so that it uses the context object and specified the View permission.

Create a Python script in your acquisition path (I used portal_skins/custom) named can_view and paste in this code:
permission = "View"
  if not object.acquiredRolesAreUsedBy( permission ):
    for p in object.rolesOfPermission( permission ):
      if p['selected']:
        if p['name'] in user.getRoles():
          return 1
   return 1
return 0
Then you can check the permission in TAL like this:


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}