Use either obj.__parent__or aq_parent(obj) instead of obj.aq_parent.

Both are the canonical forms of getting to an object's parent now.
parent 9ba2c98f
...@@ -101,7 +101,7 @@ def rolesForPermissionOn(perm, object, default=_default_roles, n=None): ...@@ -101,7 +101,7 @@ def rolesForPermissionOn(perm, object, default=_default_roles, n=None):
object = getattr(object, 'aq_inner', None) object = getattr(object, 'aq_inner', None)
if object is None: if object is None:
break break
object = object.aq_parent object = object.__parent__
if r is None: if r is None:
if _embed_permission_in_roles: if _embed_permission_in_roles:
......
...@@ -21,7 +21,7 @@ from AccessControl import ClassSecurityInfo ...@@ -21,7 +21,7 @@ from AccessControl import ClassSecurityInfo
from AccessControl import getSecurityManager, Unauthorized from AccessControl import getSecurityManager, Unauthorized
from AccessControl.Permissions import view_management_screens from AccessControl.Permissions import view_management_screens
from AccessControl.Permissions import take_ownership from AccessControl.Permissions import take_ownership
from Acquisition import aq_get, aq_parent, aq_base from Acquisition import aq_get, aq_parent, aq_base, aq_inner
from requestmethod import requestmethod from requestmethod import requestmethod
from zope.interface import implements from zope.interface import implements
...@@ -236,12 +236,12 @@ class Owned(ExtensionClass.Base): ...@@ -236,12 +236,12 @@ class Owned(ExtensionClass.Base):
def manage_fixupOwnershipAfterAdd(self): def manage_fixupOwnershipAfterAdd(self):
# Sigh, get the parent's _owner # Sigh, get the parent's _owner
parent=getattr(self, 'aq_parent', None) parent=getattr(self, '__parent__', None)
if parent is not None: _owner=aq_get(parent, '_owner', None, 1) if parent is not None: _owner=aq_get(parent, '_owner', None, 1)
else: _owner=None else: _owner=None
if (_owner is None and if (_owner is None and
((not hasattr(self, 'aq_parent')) or ((not getattr(self, '__parent__', None) is None) or
(not hasattr(self, 'getPhysicalRoot')) (not hasattr(self, 'getPhysicalRoot'))
) )
): ):
...@@ -298,13 +298,13 @@ def ownerInfo(user, getattr=getattr): ...@@ -298,13 +298,13 @@ def ownerInfo(user, getattr=getattr):
return None return None
uid=user.getId() uid=user.getId()
if uid is None: return uid if uid is None: return uid
db=user.aq_inner.aq_parent db=aq_parent(aq_inner(user))
path=[absattr(db.id)] path=[absattr(db.id)]
root=db.getPhysicalRoot() root=db.getPhysicalRoot()
while 1: while 1:
db=getattr(db,'aq_inner', None) db=getattr(db,'aq_inner', None)
if db is None: break if db is None: break
db=db.aq_parent db=aq_parent(db)
if db is root: break if db is root: break
id=db.id id=db.id
if not isinstance(id, str): if not isinstance(id, str):
......
...@@ -105,7 +105,7 @@ class RoleManager: ...@@ -105,7 +105,7 @@ class RoleManager:
return r return r
def _isBeingAccessedAsZClassDefinedInstanceMethod(self): def _isBeingAccessedAsZClassDefinedInstanceMethod(self):
p=getattr(self,'aq_parent',None) p=getattr(self,'__parent__',None)
if p is None: return 0 # Not wrapped if p is None: return 0 # Not wrapped
base=getattr(p, 'aq_base', None) base=getattr(p, 'aq_base', None)
return type(base) is PermissionMapper return type(base) is PermissionMapper
......
...@@ -188,7 +188,7 @@ class RoleManager(ExtensionClass.Base, PermissionMapping.RoleManager): ...@@ -188,7 +188,7 @@ class RoleManager(ExtensionClass.Base, PermissionMapping.RoleManager):
if userObj: if userObj:
break break
else: else:
current = current.aq_parent current = current.__parent__
newSecurityManager(None, userObj) # necessary? newSecurityManager(None, userObj) # necessary?
...@@ -414,7 +414,7 @@ class RoleManager(ExtensionClass.Base, PermissionMapping.RoleManager): ...@@ -414,7 +414,7 @@ class RoleManager(ExtensionClass.Base, PermissionMapping.RoleManager):
raise OverflowError raise OverflowError
for name in unl: for name in unl:
dict[name]=1 dict[name]=1
item = getattr(item, 'aq_parent', _notfound) item = getattr(item, '__parent__', _notfound)
if item is _notfound: if item is _notfound:
break break
keys=dict.keys() keys=dict.keys()
...@@ -511,9 +511,9 @@ class RoleManager(ExtensionClass.Base, PermissionMapping.RoleManager): ...@@ -511,9 +511,9 @@ class RoleManager(ExtensionClass.Base, PermissionMapping.RoleManager):
for role in roles: for role in roles:
if not dup(role): if not dup(role):
dict[role]=1 dict[role]=1
if not hasattr(obj, 'aq_parent'): if getattr(obj, '__parent__', None) is None:
break break
obj=obj.aq_parent obj=obj.__parent__
x=x+1 x=x+1
roles=dict.keys() roles=dict.keys()
roles.sort() roles.sort()
......
...@@ -106,7 +106,7 @@ class BasicUser(Implicit): ...@@ -106,7 +106,7 @@ class BasicUser(Implicit):
for r in dict.get(userid, []): for r in dict.get(userid, []):
local[r]=1 local[r]=1
inner = getattr(object, 'aq_inner', object) inner = getattr(object, 'aq_inner', object)
parent = getattr(inner, 'aq_parent', None) parent = getattr(inner, '__parent__', None)
if parent is not None: if parent is not None:
object = parent object = parent
continue continue
...@@ -148,10 +148,10 @@ class BasicUser(Implicit): ...@@ -148,10 +148,10 @@ class BasicUser(Implicit):
else: else:
try: return r+list(roles) try: return r+list(roles)
except: return r except: return r
if hasattr(parent, 'aq_parent'): if getattr(parent, '__parent__', None) is not None:
while hasattr(parent.aq_self,'aq_self'): while hasattr(parent.aq_self,'aq_self'):
parent=parent.aq_self parent = parent.aq_self
parent=parent.aq_parent parent = parent.__parent__
else: return r else: return r
def _check_context(self, object): def _check_context(self, object):
...@@ -160,8 +160,8 @@ class BasicUser(Implicit): ...@@ -160,8 +160,8 @@ class BasicUser(Implicit):
# to prevent "stealing" access through acquisition tricks. # to prevent "stealing" access through acquisition tricks.
# Return true if in context, false if not or if context # Return true if in context, false if not or if context
# cannot be determined (object is not wrapped). # cannot be determined (object is not wrapped).
parent = getattr(self, 'aq_parent', None) parent = getattr(self, '__parent__', None)
context = getattr(parent, 'aq_parent', None) context = getattr(parent, '__parent__', None)
if context is not None: if context is not None:
if object is None: if object is None:
return 1 return 1
...@@ -230,7 +230,7 @@ class BasicUser(Implicit): ...@@ -230,7 +230,7 @@ class BasicUser(Implicit):
return 1 return 1
return 0 return 0
inner = getattr(inner_obj, 'aq_inner', inner_obj) inner = getattr(inner_obj, 'aq_inner', inner_obj)
parent = getattr(inner, 'aq_parent', None) parent = getattr(inner, '__parent__', None)
if parent is not None: if parent is not None:
inner_obj = parent inner_obj = parent
continue continue
...@@ -751,11 +751,11 @@ class BasicUserFolder(Implicit, Persistent, Navigation, Tabs, RoleManager, ...@@ -751,11 +751,11 @@ class BasicUserFolder(Implicit, Persistent, Navigation, Tabs, RoleManager,
request.RESPONSE.notFoundError('no default view (root default view' request.RESPONSE.notFoundError('no default view (root default view'
' was probably deleted)') ' was probably deleted)')
n = request.steps[-1] n = request.steps[-1]
# default to accessed and container as v.aq_parent # default to accessed and container as v.__parent__
a = c = request['PARENTS'][0] a = c = request['PARENTS'][0]
# try to find actual container # try to find actual container
inner = getattr(v, 'aq_inner', v) inner = getattr(v, 'aq_inner', v)
innerparent = getattr(inner, 'aq_parent', None) innerparent = getattr(inner, '__parent__', None)
if innerparent is not None: if innerparent is not None:
# this is not a method, we needn't treat it specially # this is not a method, we needn't treat it specially
c = innerparent c = innerparent
...@@ -763,8 +763,8 @@ class BasicUserFolder(Implicit, Persistent, Navigation, Tabs, RoleManager, ...@@ -763,8 +763,8 @@ class BasicUserFolder(Implicit, Persistent, Navigation, Tabs, RoleManager,
# this is a method, we need to treat it specially # this is a method, we need to treat it specially
c = v.im_self c = v.im_self
c = getattr(v, 'aq_inner', v) c = getattr(v, 'aq_inner', v)
request_container = getattr(request['PARENTS'][-1], 'aq_parent', []) request_container = getattr(request['PARENTS'][-1], '__parent__', [])
# if pub's aq_parent or container is the request container, it # if pub's __parent__ or container is the request container, it
# means pub was accessed from the root # means pub was accessed from the root
if a is request_container: if a is request_container:
a = request['PARENTS'][-1] a = request['PARENTS'][-1]
...@@ -775,7 +775,7 @@ class BasicUserFolder(Implicit, Persistent, Navigation, Tabs, RoleManager, ...@@ -775,7 +775,7 @@ class BasicUserFolder(Implicit, Persistent, Navigation, Tabs, RoleManager,
def _isTop(self): def _isTop(self):
try: try:
return self.aq_parent.aq_base.isTopLevelPrincipiaApplicationObject return self.__parent__.aq_base.isTopLevelPrincipiaApplicationObject
except: except:
return 0 return 0
......
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