Commit 4ed67d05 authored by Jim Fulton's avatar Jim Fulton

Changed the __of__ method of PermissionRole to go ahead and compute

the roles if it is called with a wrapped object.

Changed the role computing logic to always use aq_inner when getting
a parent to make sure it follows the containment context.
parent 592160b6
...@@ -85,8 +85,8 @@ ...@@ -85,8 +85,8 @@
__doc__='''Objects that implement Permission-based roles. __doc__='''Objects that implement Permission-based roles.
$Id: PermissionRole.py,v 1.7 1999/07/21 13:13:28 jim Exp $''' $Id: PermissionRole.py,v 1.8 2000/11/20 10:51:21 jim Exp $'''
__version__='$Revision: 1.7 $'[11:-2] __version__='$Revision: 1.8 $'[11:-2]
import sys import sys
...@@ -122,12 +122,16 @@ class PermissionRole(Base): ...@@ -122,12 +122,16 @@ class PermissionRole(Base):
self._p='_'+string.translate(name,name_trans)+"_Permission" self._p='_'+string.translate(name,name_trans)+"_Permission"
self._d=default self._d=default
def __of__(self, parent): def __of__(self, parent, None=None, getattr=getattr):
r=imPermissionRole() r=imPermissionRole()
r._p=self._p r._p=self._p
r._pa=parent r._pa=parent
r._d=self._d r._d=self._d
return r p=getattr(parent, 'aq_inner', None)
if p is not None:
return r.__of__(p)
else:
return r
_what_not_even_god_should_do=[] _what_not_even_god_should_do=[]
...@@ -136,7 +140,7 @@ class imPermissionRole(Base): ...@@ -136,7 +140,7 @@ class imPermissionRole(Base):
"""Implement permission-based roles """Implement permission-based roles
""" """
def __of__(self, parent, tt=type(()), st=type('')): def __of__(self, parent,tt=type(()),st=type(''),getattr=getattr,None=None):
obj=parent obj=parent
n=self._p n=self._p
r=None r=None
...@@ -169,11 +173,10 @@ class imPermissionRole(Base): ...@@ -169,11 +173,10 @@ class imPermissionRole(Base):
elif roles: elif roles:
if r is None: r=list(roles) if r is None: r=list(roles)
else: r=r+list(roles) else: r=r+list(roles)
if hasattr(obj,'aq_parent'): obj=getattr(obj, 'aq_inner', None)
obj=obj.aq_parent if obj is None: break
else: obj=obj.aq_parent
break
if r is None: r=self._d if r is None: r=self._d
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment