Commit 1777c67a authored by Brian Lloyd's avatar Brian Lloyd

Merged fixes for 332.

parent bebc1897
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
"""WebDAV support - null resource objects.""" """WebDAV support - null resource objects."""
__version__='$Revision: 1.36 $'[11:-2] __version__='$Revision: 1.37 $'[11:-2]
import sys, os, mimetypes, Globals, davcmds import sys, os, mimetypes, Globals, davcmds
import Acquisition, OFS.content_types import Acquisition, OFS.content_types
...@@ -25,7 +25,7 @@ from Globals import Persistent, DTMLFile ...@@ -25,7 +25,7 @@ from Globals import Persistent, DTMLFile
from WriteLockInterface import WriteLockInterface from WriteLockInterface import WriteLockInterface
import OFS.SimpleItem import OFS.SimpleItem
from zExceptions import Unauthorized from zExceptions import Unauthorized
from common import isDavCollection
class NullResource(Persistent, Acquisition.Implicit, Resource): class NullResource(Persistent, Acquisition.Implicit, Resource):
"""Null resources are used to handle HTTP method calls on """Null resources are used to handle HTTP method calls on
...@@ -137,7 +137,7 @@ class NullResource(Persistent, Acquisition.Implicit, Resource): ...@@ -137,7 +137,7 @@ class NullResource(Persistent, Acquisition.Implicit, Resource):
if hasattr(aq_base(parent), name): if hasattr(aq_base(parent), name):
raise 'Method Not Allowed', 'The name %s is in use.' % name raise 'Method Not Allowed', 'The name %s is in use.' % name
if not hasattr(parent, '__dav_collection__'): if not isDavCollection(parent):
raise 'Forbidden', 'Cannot create collection at this location.' raise 'Forbidden', 'Cannot create collection at this location.'
ifhdr = REQUEST.get_header('If', '') ifhdr = REQUEST.get_header('If', '')
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
"""WebDAV support - resource objects.""" """WebDAV support - resource objects."""
__version__='$Revision: 1.50 $'[11:-2] __version__='$Revision: 1.51 $'[11:-2]
import sys, os, mimetypes, davcmds, ExtensionClass, Lockable import sys, os, mimetypes, davcmds, ExtensionClass, Lockable
from common import absattr, aq_base, urlfix, rfc1123_date, tokenFinder, urlbase from common import absattr, aq_base, urlfix, rfc1123_date, tokenFinder, urlbase
...@@ -24,6 +24,7 @@ from WriteLockInterface import WriteLockInterface ...@@ -24,6 +24,7 @@ from WriteLockInterface import WriteLockInterface
import Globals, time import Globals, time
from ZPublisher.HTTPRangeSupport import HTTPRangeInterface from ZPublisher.HTTPRangeSupport import HTTPRangeInterface
from zExceptions import Unauthorized from zExceptions import Unauthorized
from common import isDavCollection
class Resource(ExtensionClass.Base, Lockable.LockableItem): class Resource(ExtensionClass.Base, Lockable.LockableItem):
"""The Resource mixin class provides basic WebDAV support for """The Resource mixin class provides basic WebDAV support for
...@@ -357,7 +358,7 @@ class Resource(ExtensionClass.Base, Lockable.LockableItem): ...@@ -357,7 +358,7 @@ class Resource(ExtensionClass.Base, Lockable.LockableItem):
ob.wl_clearLocks() ob.wl_clearLocks()
ob._setId(name) ob._setId(name)
if depth=='0' and hasattr(ob, '__dav_collection__'): if depth=='0' and isDavCollection(ob):
for id in ob.objectIds(): for id in ob.objectIds():
ob._delObject(id) ob._delObject(id)
if existing: if existing:
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
"""Commonly used functions for WebDAV support modules.""" """Commonly used functions for WebDAV support modules."""
__version__='$Revision: 1.15 $'[11:-2] __version__='$Revision: 1.16 $'[11:-2]
import time, urllib, re import time, urllib, re
from App.Common import iso8601_date, rfc850_date, rfc1123_date from App.Common import iso8601_date, rfc850_date, rfc1123_date
...@@ -59,7 +59,9 @@ def generateLockToken(): ...@@ -59,7 +59,9 @@ def generateLockToken():
return '%s-%s-00105A989226:%.03f' % \ return '%s-%s-00105A989226:%.03f' % \
(_randGen.random(),_randGen.random(),time.time()) (_randGen.random(),_randGen.random(),time.time())
def isDavCollection(object):
"""Return true if object is a DAV collection."""
return getattr(object, '__dav_collection__', 0)
def tokenFinder(token): def tokenFinder(token):
# takes a string like '<opaquelocktoken:afsdfadfadf> and returns the token # takes a string like '<opaquelocktoken:afsdfadfadf> and returns the token
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
"""WebDAV xml request objects.""" """WebDAV xml request objects."""
__version__='$Revision: 1.18 $'[11:-2] __version__='$Revision: 1.19 $'[11:-2]
import sys, os import sys, os
from common import absattr, aq_base, urlfix, urlbase from common import absattr, aq_base, urlfix, urlbase
...@@ -25,6 +25,7 @@ from xmltools import XmlParser ...@@ -25,6 +25,7 @@ from xmltools import XmlParser
from cStringIO import StringIO from cStringIO import StringIO
from urllib import quote from urllib import quote
from AccessControl import getSecurityManager from AccessControl import getSecurityManager
from common import isDavCollection
def safe_quote(url, mark=r'%'): def safe_quote(url, mark=r'%'):
if url.find(mark) > -1: if url.find(mark) > -1:
...@@ -90,7 +91,7 @@ class PropFind: ...@@ -90,7 +91,7 @@ class PropFind:
url=urlbase(url) url=urlbase(url)
result.write('<?xml version="1.0" encoding="utf-8"?>\n' \ result.write('<?xml version="1.0" encoding="utf-8"?>\n' \
'<d:multistatus xmlns:d="DAV:">\n') '<d:multistatus xmlns:d="DAV:">\n')
iscol=hasattr(obj, '__dav_collection__') iscol=isDavCollection(obj)
if iscol and url[-1] != '/': url=url+'/' if iscol and url[-1] != '/': url=url+'/'
result.write('<d:response>\n<d:href>%s</d:href>\n' % safe_quote(url)) result.write('<d:response>\n<d:href>%s</d:href>\n' % safe_quote(url))
if hasattr(aq_base(obj), 'propertysheets'): if hasattr(aq_base(obj), 'propertysheets'):
...@@ -209,7 +210,7 @@ class PropPatch: ...@@ -209,7 +210,7 @@ class PropPatch:
def apply(self, obj): def apply(self, obj):
url=urlfix(self.request['URL'], 'PROPPATCH') url=urlfix(self.request['URL'], 'PROPPATCH')
if hasattr(obj, '__dav_collection__'): if isDavCollection(obj):
url=url+'/' url=url+'/'
result=StringIO() result=StringIO()
errors=[] errors=[]
...@@ -323,7 +324,7 @@ class Lock: ...@@ -323,7 +324,7 @@ class Lock:
result = StringIO() result = StringIO()
url = urlfix(self.request['URL'], 'LOCK') url = urlfix(self.request['URL'], 'LOCK')
url = urlbase(url) url = urlbase(url)
iscol = hasattr(obj, '__dav_collection__') iscol = isDavCollection(obj)
if iscol and url[-1] != '/': url = url + '/' if iscol and url[-1] != '/': url = url + '/'
errmsg = None errmsg = None
lock = None lock = None
...@@ -397,7 +398,7 @@ class Unlock: ...@@ -397,7 +398,7 @@ class Unlock:
result = StringIO() result = StringIO()
url = urlfix(url, 'UNLOCK') url = urlfix(url, 'UNLOCK')
url = urlbase(url) url = urlbase(url)
iscol = hasattr(obj, '__dav_collection__') iscol = isDavCollection(obj)
if iscol and url[-1] != '/': url = url + '/' if iscol and url[-1] != '/': url = url + '/'
errmsg = None errmsg = None
...@@ -455,7 +456,7 @@ class DeleteCollection: ...@@ -455,7 +456,7 @@ class DeleteCollection:
result = StringIO() result = StringIO()
url = urlfix(url, 'DELETE') url = urlfix(url, 'DELETE')
url = urlbase(url) url = urlbase(url)
iscol = hasattr(obj, '__dav_collection__') iscol = isDavCollection(obj)
errmsg = None errmsg = None
parent = aq_parent(obj) parent = aq_parent(obj)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment