[Zope-Checkins] CVS: Zope/lib/python/webdav - Resource.py:1.48.6.4 webdav_magic.py:1.1.2.5
Andreas Jung
andreas@zope.com
Wed, 7 Nov 2001 11:01:52 -0500
Update of /cvs-repository/Zope/lib/python/webdav
In directory cvs.zope.org:/tmp/cvs-serv10865/lib/python/webdav
Modified Files:
Tag: ajung-webdav-debug
Resource.py webdav_magic.py
Log Message:
added support to disable WebDAV locking based on the user-agent *sigh*
=== Zope/lib/python/webdav/Resource.py 1.48.6.3 => 1.48.6.4 ===
from ZPublisher.HTTPRangeSupport import HTTPRangeInterface
from zExceptions import Unauthorized
+from webdav_magic import buggy_agents
webdav_magic_enabled = 0
+disable_locking_for_buggy_clients = 0
+
class Resource(ExtensionClass.Base, Lockable.LockableItem):
"""The Resource mixin class provides basic WebDAV support for
@@ -257,7 +260,13 @@
def OPTIONS(self, REQUEST, RESPONSE):
"""Retrieve communication options."""
self.dav__init(REQUEST, RESPONSE)
- RESPONSE.setHeader('Allow', string.join(self.__http_methods__,', '))
+
+ if disable_locking_for_buggy_clients==1 and \
+ buggy_agents(REQUEST.get("HTTP_USER_AGENT","")):
+ RESPONSE.setHeader('Allow', ', '.join(self.__http_methods__[:-2]))
+ else:
+ RESPONSE.setHeader('Allow', ', '.join(self.__http_methods__))
+
RESPONSE.setHeader('Content-Length', 0)
RESPONSE.setHeader('DAV', '1,2', 1)
RESPONSE.setStatus(200)
@@ -552,6 +561,12 @@
def LOCK(self, REQUEST, RESPONSE):
"""Lock a resource"""
+
+ if disable_locking_for_buggy_clients==1 and \
+ buggy_agents(REQUEST.get("HTTP_USER_AGENT","")):
+
+ raise 'Method Not Allowed', 'Method not supported for this resource.'
+
self.dav__init(REQUEST, RESPONSE)
security = getSecurityManager()
creator = security.getUser()
@@ -610,6 +625,12 @@
def UNLOCK(self, REQUEST, RESPONSE):
"""Remove an existing lock on a resource."""
+
+ if disable_locking_for_buggy_clients==1 and \
+ buggy_agents(REQUEST.get("HTTP_USER_AGENT","")):
+
+ raise 'Method Not Allowed', 'Method not supported for this resource.'
+
self.dav__init(REQUEST, RESPONSE)
security = getSecurityManager()
user = security.getUser()
=== Zope/lib/python/webdav/webdav_magic.py 1.1.2.4 => 1.1.2.5 ===
__version__='$Id$'
-import OFS.Image
import re, cStringIO
suffix_reg = re.compile('(\.[a-zA-Z]*$)')
@@ -98,7 +97,12 @@
).search
+buggy_agents = re.compile( '(Microsoft Data Access.*DAV)'
+ ).search
+
+
def cloneFile(ob,destId,mime_type):
+ import OFS.Image
file = OFS.Image.File(destId, title=destId,
file=cStringIO.StringIO(),