[Zope-Coders] Re: [Zope-Checkins] CVS: Zope/lib/python/OFS - Traversable.py:1.19

Tres Seaver tseaver@zope.com
17 Apr 2003 14:41:52 -0400


On Thu, 2003-04-17 at 13:46, Fred L. Drake, Jr. wrote:
> Update of /cvs-repository/Zope/lib/python/OFS
> In directory cvs.zope.org:/tmp/cvs-serv27014
> 
> Modified Files:
> 	Traversable.py 
> Log Message:
> - give nearly-anonymous exception a local name
> - modernize a type-check

Note that this NotFound and the one in ZPublisher have nothing to do
with one another. :)  We need an Exceptions.py which holds all of the
string exception objects, if we are going this route.
> 
> 
> === Zope/lib/python/OFS/Traversable.py 1.18 => 1.19 ===
> --- Zope/lib/python/OFS/Traversable.py:1.18	Wed Feb 26 11:51:46 2003
> +++ Zope/lib/python/OFS/Traversable.py	Thu Apr 17 13:46:57 2003
> @@ -22,8 +22,9 @@
>  from AccessControl.ZopeGuards import guarded_getattr
>  from urllib import quote
>  
> +NotFound = 'NotFound'
> +
>  _marker=[]
> -StringType=type('')
>  
>  class Traversable:
>  
> @@ -75,7 +76,7 @@
>          N=None
>          M=_marker
>  
> -        if type(path) is StringType: path = path.split('/')
> +        if isinstance(path, str): path = path.split('/')
>          else: path=list(path)
>  
>          REQUEST={'TraversalRequestNameStack': path}
> @@ -104,7 +105,7 @@
>  
>                  if name[0] == '_':
>                      # Never allowed in a URL.
> -                    raise 'NotFound', name
> +                    raise NotFound, name
>  
>                  if name=='..':
>                      o=getattr(object, 'aq_parent', M)
> @@ -143,8 +144,8 @@
>                          try:
>                              o=object[name]
>                          except AttributeError:
> -                            # Raise a NotFound for easier debugging
> -                            raise 'NotFound', name
> +                            # Raise NotFound for easier debugging
> +                            raise NotFound, name
>                          if (restricted and not securityManager.validate(
>                              object, object, N, o)):
>                              raise Unauthorized, name
> 
> 
> _______________________________________________
> Zope-Checkins maillist  -  Zope-Checkins@zope.org
> http://mail.zope.org/mailman/listinfo/zope-checkins
-- 
===============================================================
Tres Seaver                                tseaver@zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com