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

Merged fixes for 332.

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