[Zope-dev] Zope 2, WebDAV and browser-default
Martin Aspeli
optilude+lists at gmail.com
Sun Oct 4 22:59:18 EDT 2009
Hi,
I came across this trying to implement WebDAV support for some content in Zope 2.
The ZPublisher will always traverse to the return value from 'browserDefault()'
(either from a custom IBrowserPublisher adapter, or the DefaultPublishTraverse
object hardcoded in ZPublisher.BaseRequest) when it gets to the end of a
traversal chain, even for WebDAV requests.
This makes it impossible to e.g. get a folder listing in WebDAV.
The default 'browserDefault()' will call __browser_default__() on the context if
that exists. If not, it will call queryDefaultView(), which returns a view name
as set by a <browser:defaultView /> directive, and return that name unless it is
None. The publisher will then traverse to the name indicated.
This breaks WebDAV in two ways: Consider a folder /foo/bar. The class for 'bar'
does not implement __browser_default__(), but there is a default view, set with
the <browser:defaultView /> directive, called 'index'.
Let's say the WebDAV client attempts to do a PROPFIND request to list the
folder's contents. The publisher will traverse to /foo/bar and then look up the
default view, @@index, and attempt to traverse to that. This doesn't have the
PROPFIND() verb method, obviously, since views don't derive from
webdav.Resource, and so the WebDAV requests fails.
Even if it does, there's some code at the end of BaseRequest.traverse() which
checks that the last item in the traversal chain is *not* acquired (i.e. it's a
genuine child of the aq_base'd second-to-last item). This is to allow PUT'ing to
a name that could've been acquired (via the NullResource mechanism).
This means that if you have registered a <browser:defaultView /> for an object,
it is impossible for that object to participate in WebDAV requests.
We never noticed in Plone before, because most Plone content implements
__browser_default__ so that it delegates to PloneTool.browserDefault() which
aborts immediately if it detects a WebDAV request.
The default behaviour does *not* do this, however, and it seems wrong to expect
everyone who implements __browser_default__ or an IBrowserPublisher adapter to
have to do so.
My suggestion would be that we simply skip the browserDefault() lookup for
WebDAV requests. I don't think it's meaningful to have a browser-default page
when looking at objects via WebDAV at all.
I can make the change as a bugfix to 2.10, 2.11 and 2.12 if no-one objects.
Martin
More information about the Zope-Dev
mailing list