[Zope-dev] unrestrictedTraverse and URLs ending in slash.
   
    Lennart Regebro
     
    lennart@regebro.nu
       
    Thu, 17 Jan 2002 16:15:05 +0100
    
    
  
I quite often use URLs that end in a slash (in fact, I prefer it that way,
since I then can add methods easily without having to care about if the url
is the root '/' or another object). This got me into trouble, though, since
unrestrictedtraverse can't handle URLs that end in a slash.
I have patched it in my 2.3.4 installation so that it does, and think it
would be a good idea to include this fix in Zope. What do you others think?
>> OFS.Traversable Line 68:
    unrestrictedTraverse__roles__=() # Private
    def unrestrictedTraverse(self, path, default=_marker, restricted=0):
        if not path: return self
        get=getattr
        has=hasattr
        N=None
        M=_marker
        if type(path) is StringType:
            if (path[-1] == '/') and (path != '/'):  path = path [:-1] #
Handle URL's that end in a slash.
            path = split(path,'/')
        else: path=list(path)