[Zope] Re: WebDAV turds...
Chris Withers
chris at simplistix.co.uk
Wed Jul 28 13:57:31 EDT 2004
Vahur Rebas wrote:
>
> I'm now bugging you again.
Dump the following in a file called __init__.py in a folder called
WebDAVPatch in your Products directory:
# Disable MS-Author-via = DAV by monkey patch
from ZPublisher.HTTPRangeSupport import HTTPRangeInterface
from webdav.Resource import Resource, rfc1123_date
def dav__init(self, request, response):
# Init expected HTTP 1.1 / WebDAV headers which are not
# currently set by the base response object automagically.
#
# Note we set an borg-specific header for ie5 :( Also, we
# sniff for a ZServer response object, because we don't
# want to write duplicate headers (since ZS writes Date
# and Connection itself).
if not hasattr(response, '_server_version'):
response.setHeader('Connection', 'close')
response.setHeader('Date', rfc1123_date(), 1)
# response.setHeader('MS-Author-Via', 'DAV')
# HTTP Range support
if HTTPRangeInterface.isImplementedBy(self):
response.setHeader('Accept-Ranges', 'bytes')
else:
response.setHeader('Accept-Ranges', 'none')
Resource.dav__init = dav__init
def OPTIONS(self, REQUEST, RESPONSE):
"""Retrieve communication options."""
self.dav__init(REQUEST, RESPONSE)
RESPONSE.setHeader('Allow', ', '.join(self.__http_methods__))
RESPONSE.setHeader('Content-Length', 0)
# RESPONSE.setHeader('DAV', '1,2', 1)
RESPONSE.setStatus(200)
return RESPONSE
Resource.OPTIONS = OPTIONS
from webdav.Collection import Collection, rfc1123_date
def dav__init(self, request, response):
# We are allowed to accept a url w/o a trailing slash
# for a collection, but are supposed to provide a
# hint to the client that it should be using one.
# [WebDAV, 5.2]
pathinfo=request.get('PATH_INFO','')
if pathinfo and pathinfo[-1] != '/':
location='%s/' % request['URL1']
response.setHeader('Content-Location', location)
response.setHeader('Connection', 'close', 1)
response.setHeader('Date', rfc1123_date(), 1)
# response.setHeader('MS-Author-Via', 'DAV')
Collection.dav__init = dav__init
As a note to anyone reading, this crap will be GOING AWAY on both the
2.7 branch and the HEAD this Friday unless someone can give me some
compelling reason for it not to ;-)
http://zope.org/Collectors/Zope/1441
cheers,
Chris
--
Simplistix - Content Management, Zope & Python Consulting
- http://www.simplistix.co.uk
More information about the Zope
mailing list