[Zope-dev] Another OFS.Traversable and ZPublisher inconsistency

Martin Aspeli optilude+lists at gmail.com
Sat May 23 01:00:22 EDT 2009


Hi,

So, we determined that OFS.Traversable's unrestrictedTraverse() 
shouldn't grow support for IPublishTraverse, which is fair enough. We're 
now using an ITraversable adapter instead (++namespace++).

However, we found another inconsistency. In URL traversal, this works:

  /foo/bar/++namespace++/123

In OFS.Traversable, it doesn't, but this does:

  /foo/bar/++namespace++blah/123

The reason is that in restrictedTraverse(), we have this check:

   if name and name[:1] in '@+' and name != '+' and nsParse(name)[1]:
       ns, nm = nsParse(name)

However, nsParse(name)[1] is '' if no name is provided after the namespace.

In BaseRequest.traverseName() we have a similar, but more relaxed check:

   if name and name[:1] in '@+'
       ns, nm = nsParse(name)
       if ns:
           ...

This also has the advantage of not calling nsParse() twice.

I can't understand why OFS.Traversable would explicitly disallow 
namespace traversal with an empty string as the name. Is this on 
purpose, or a bug?

Cheers,
Martin

-- 
Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book



More information about the Zope-Dev mailing list