Use the canonical form for getting to an object's innermost wrapper

and an object's parent by usingn the aq_parent and aq_inner *functions*,
not attributes.
parent 167ca213
...@@ -20,6 +20,7 @@ from AccessControl.Permissions import view_management_screens ...@@ -20,6 +20,7 @@ from AccessControl.Permissions import view_management_screens
from AccessControl.PermissionRole import _what_not_even_god_should_do from AccessControl.PermissionRole import _what_not_even_god_should_do
from AccessControl.ZopeGuards import guarded_getattr from AccessControl.ZopeGuards import guarded_getattr
from Persistence import Persistent from Persistence import Persistent
from Acquisition import aq_parent, aq_inner
from string import join, strip from string import join, strip
import re import re
...@@ -271,11 +272,11 @@ class Bindings: ...@@ -271,11 +272,11 @@ class Bindings:
def _getContext(self): def _getContext(self):
# Utility for bindcode. # Utility for bindcode.
while 1: while 1:
self = self.aq_parent self = aq_parent(self)
if not getattr(self, '_is_wrapperish', None): if not getattr(self, '_is_wrapperish', None):
parent = getattr(self, 'aq_parent', None) parent = aq_parent(self)
inner = getattr(self, 'aq_inner', None) inner = aq_inner(self)
container = getattr(inner, 'aq_parent', None) container = aq_parent(inner)
try: getSecurityManager().validate(parent, container, '', self) try: getSecurityManager().validate(parent, container, '', self)
except Unauthorized: except Unauthorized:
return UnauthorizedBinding('context', self) return UnauthorizedBinding('context', self)
...@@ -284,11 +285,11 @@ class Bindings: ...@@ -284,11 +285,11 @@ class Bindings:
def _getContainer(self): def _getContainer(self):
# Utility for bindcode. # Utility for bindcode.
while 1: while 1:
self = self.aq_inner.aq_parent self = aq_parent(aq_inner(self))
if not getattr(self, '_is_wrapperish', None): if not getattr(self, '_is_wrapperish', None):
parent = getattr(self, 'aq_parent', None) parent = aq_parent(self)
inner = getattr(self, 'aq_inner', None) inner = aq_inner(self)
container = getattr(inner, 'aq_parent', None) container = aq_parent(inner)
try: getSecurityManager().validate(parent, container, '', self) try: getSecurityManager().validate(parent, container, '', self)
except Unauthorized: except Unauthorized:
return UnauthorizedBinding('container', self) return UnauthorizedBinding('container', self)
......
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