Inconsistent aq-wrapping in BaseRequest's traverseName()
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Zope 2 |
Invalid
|
Medium
|
Unassigned |
Bug Description
I *think* this is a bug, opinions welcome :)
In ZPublisher/
def traverseName(self, ob, name):
if name and name[:1] in '@+':
# Process URI segment parameters.
ns, nm = nsParse(name)
if ns:
if name == '.':
return ob
if IPublishTravers
ob2 = ob.publishTrave
else:
adapter = queryMultiAdapt
if adapter is None:
## Zope2 doesn't set up its own adapters in a lot of cases
## so we will just use a default adapter.
ob2 = adapter.
return ob2
Notice that when it does a namespaceLookup, it will aq-wrap the result. Thus, if you write an ITraversable adapter for a ++foo++ namespace, you should not aq-wrap the result. This is generally good IMHO, because it makes it possible to re-use pure-Zope3 adapters.
Now, if we do a publishTraverse() the result is not aq-wrapped, leading to the usual problems (like the bizarre authentication errors that stung me). It also means that you have to write your own IPublishTraverse adapter for things like containers. For example, if you try to traverse to the content of a Zope 3 style container, zope.app.
Note that IPublishTraverse may also look up views and return them, which also need to be aq-wrapped.
This still applies to current Zope 2.12 code. But given that this has worked for years, I'm not sure if we should change it.