[Zope-Checkins] CVS: Zope2 - Resource.py:1.37.16.3
Brian Lloyd
brian@digicool.com
Tue, 27 Mar 2001 14:25:56 -0500 (EST)
Update of /cvs-repository/Zope2/lib/python/webdav
In directory korak:/home/brian/temp/zope-23-branch/lib/python/webdav
Modified Files:
Tag: zope-2_3-branch
Resource.py
Log Message:
Fixed COPY to handle Destination urls better
--- Updated File Resource.py in package Zope2 --
--- Resource.py 2001/03/27 14:11:43 1.37.16.2
+++ Resource.py 2001/03/27 19:25:55 1.37.16.3
@@ -256,20 +256,29 @@
if not hasattr(aq_base(self), 'cb_isCopyable') or \
not self.cb_isCopyable():
raise 'Method Not Allowed', 'This object may not be copied.'
+
depth=REQUEST.get_header('Depth', 'infinity')
if not depth in ('0', 'infinity'):
raise 'Bad Request', 'Invalid Depth header.'
+
dest=REQUEST.get_header('Destination', '')
while dest and dest[-1]=='/':
dest=dest[:-1]
if not dest:
raise 'Bad Request', 'Invalid Destination header.'
+
+ path, (bad1, bad2, pct) = REQUEST.physicalPathFromURL(dest)
+ if pct < 1 or bad2:
+ raise 'Bad Request', 'Invalid Destination header'
+
+ name = path.pop()
+ parent_path = string.join(path, '/')
+
oflag=string.upper(REQUEST.get_header('Overwrite', 'F'))
if not oflag in ('T', 'F'):
raise 'Bad Request', 'Invalid Overwrite header.'
- path, name=os.path.split(dest)
- name=unquote(name)
- try: parent=REQUEST.resolve_url(path)
+
+ try: parent=self.restrictedTraverse(path)
except ValueError:
raise 'Conflict', 'Attempt to copy to an unknown namespace.'
except 'Not Found':
@@ -317,24 +326,27 @@
if not hasattr(aq_base(self), 'cb_isMoveable') or \
not self.cb_isMoveable():
raise 'Method Not Allowed', 'This object may not be moved.'
+
dest=REQUEST.get_header('Destination', '')
path, (bad1, bad2, pct) = REQUEST.physicalPathFromURL(dest)
if pct < 1 or bad2:
raise 'Bad Request', 'No destination given'
flag=REQUEST.get_header('Overwrite', 'F')
flag=string.upper(flag)
- body=REQUEST.get('BODY', '')
+
name = path.pop()
+ parent_path = string.join(path, '/')
+
try: parent = self.restrictedTraverse(path)
except ValueError:
raise 'Conflict', 'Attempt to move to an unknown namespace.'
except 'Not Found':
- raise 'Conflict', 'The resource %s must exist.' % path
+ raise 'Conflict', 'The resource %s must exist.' % parent_path
except:
t, v, tb=sys.exc_info()
raise t, v
if hasattr(parent, '__null_resource__'):
- raise 'Conflict', 'The resource %s must exist.' % path
+ raise 'Conflict', 'The resource %s must exist.' % parent_path
existing=hasattr(aq_base(parent), name)
if existing and flag=='F':
raise 'Precondition Failed', 'Resource %s exists.' % dest