Commit b8791552 authored by Fred Drake's avatar Fred Drake

- give nearly-anonymous exception a local name

- modernize a type-check
parent a00dffc5
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
############################################################################## ##############################################################################
'''This module implements a mix-in for traversable objects. '''This module implements a mix-in for traversable objects.
$Id: Traversable.py,v 1.18 2003/02/26 16:51:46 caseman Exp $''' $Id: Traversable.py,v 1.19 2003/04/17 17:46:57 fdrake Exp $'''
__version__='$Revision: 1.18 $'[11:-2] __version__='$Revision: 1.19 $'[11:-2]
from Acquisition import Acquired, aq_inner, aq_parent, aq_base from Acquisition import Acquired, aq_inner, aq_parent, aq_base
...@@ -22,8 +22,9 @@ from AccessControl import Unauthorized ...@@ -22,8 +22,9 @@ from AccessControl import Unauthorized
from AccessControl.ZopeGuards import guarded_getattr from AccessControl.ZopeGuards import guarded_getattr
from urllib import quote from urllib import quote
NotFound = 'NotFound'
_marker=[] _marker=[]
StringType=type('')
class Traversable: class Traversable:
...@@ -75,7 +76,7 @@ class Traversable: ...@@ -75,7 +76,7 @@ class Traversable:
N=None N=None
M=_marker M=_marker
if type(path) is StringType: path = path.split('/') if isinstance(path, str): path = path.split('/')
else: path=list(path) else: path=list(path)
REQUEST={'TraversalRequestNameStack': path} REQUEST={'TraversalRequestNameStack': path}
...@@ -104,7 +105,7 @@ class Traversable: ...@@ -104,7 +105,7 @@ class Traversable:
if name[0] == '_': if name[0] == '_':
# Never allowed in a URL. # Never allowed in a URL.
raise 'NotFound', name raise NotFound, name
if name=='..': if name=='..':
o=getattr(object, 'aq_parent', M) o=getattr(object, 'aq_parent', M)
...@@ -143,8 +144,8 @@ class Traversable: ...@@ -143,8 +144,8 @@ class Traversable:
try: try:
o=object[name] o=object[name]
except AttributeError: except AttributeError:
# Raise a NotFound for easier debugging # Raise NotFound for easier debugging
raise 'NotFound', name raise NotFound, name
if (restricted and not securityManager.validate( if (restricted and not securityManager.validate(
object, object, N, o)): object, object, N, o)):
raise Unauthorized, name raise Unauthorized, name
......
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