[Zope-Checkins] CVS: Zope/lib/python/webdav - NullResource.py:1.37 Resource.py:1.51 common.py:1.16 davcmds.py:1.19

Brian Lloyd brian@zope.com
Wed, 14 Aug 2002 12:50:54 -0400


Update of /cvs-repository/Zope/lib/python/webdav
In directory cvs.zope.org:/tmp/cvs-serv932

Modified Files:
	NullResource.py Resource.py common.py davcmds.py 
Log Message:
Merged fixes for 332.


=== Zope/lib/python/webdav/NullResource.py 1.36 => 1.37 ===
--- Zope/lib/python/webdav/NullResource.py:1.36	Wed Jan  2 10:57:35 2002
+++ Zope/lib/python/webdav/NullResource.py	Wed Aug 14 12:50:53 2002
@@ -25,7 +25,7 @@
 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 @@
 
         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', '')


=== Zope/lib/python/webdav/Resource.py 1.50 => 1.51 ===
--- Zope/lib/python/webdav/Resource.py:1.50	Thu Nov 29 13:18:16 2001
+++ Zope/lib/python/webdav/Resource.py	Wed Aug 14 12:50:53 2002
@@ -24,6 +24,7 @@
 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 @@
         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:


=== Zope/lib/python/webdav/common.py 1.15 => 1.16 ===
--- Zope/lib/python/webdav/common.py:1.15	Wed Jan  9 13:38:11 2002
+++ Zope/lib/python/webdav/common.py	Wed Aug 14 12:50:53 2002
@@ -59,7 +59,9 @@
     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


=== Zope/lib/python/webdav/davcmds.py 1.18 => 1.19 ===
--- Zope/lib/python/webdav/davcmds.py:1.18	Wed Mar 13 15:47:55 2002
+++ Zope/lib/python/webdav/davcmds.py	Wed Aug 14 12:50:53 2002
@@ -25,6 +25,7 @@
 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 @@
             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 @@
 
     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 @@
             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 @@
             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 @@
             result = StringIO()
             url = urlfix(url, 'DELETE')
             url = urlbase(url)
-        iscol = hasattr(obj, '__dav_collection__')
+        iscol = isDavCollection(obj)
         errmsg = None
         parent = aq_parent(obj)