[Zope-CVS] CVS: Packages/Moztop/moztopsupport/dav - copy.py:1.2
Sidnei da Silva
sidnei@x3ng.com.br
Sat, 29 Mar 2003 16:33:04 -0500
Update of /cvs-repository/Packages/Moztop/moztopsupport/dav
In directory cvs.zope.org:/tmp/cvs-serv30740/dav
Modified Files:
copy.py
Log Message:
Barely working COPY. Something must be wrong with ObjectCopier.
=== Packages/Moztop/moztopsupport/dav/copy.py 1.1 => 1.2 ===
--- Packages/Moztop/moztopsupport/dav/copy.py:1.1 Sat Mar 29 12:09:54 2003
+++ Packages/Moztop/moztopsupport/dav/copy.py Sat Mar 29 16:33:04 2003
@@ -15,12 +15,9 @@
"""
__metaclass__ = type
-from zope.app.interfaces.file import IWriteDirectory
-from zope.app.interfaces.file import IDirectoryFactory
-from zope.app.interfaces.container import IZopeWriteContainer
-from zope.app.event import publish
-from zope.app.event.objectevent import ObjectCreatedEvent
-from zope.component import queryAdapter, getAdapter
+from zope.component import queryAdapter, getAdapter, getView
+from zope.app.interfaces.copypastemove import IObjectCopier
+from zope.app.traversing import getRoot, traverse
class COPY:
"""COPY handler
@@ -33,5 +30,25 @@
def COPY(self):
request = self.request
destination = request.getHeader('destination', '')
- request.response.setStatus(403)
+ overwrite = request.getHeader('overwrite', 'T')
+ if not destination:
+ request.response.setStatus(400)
+
+ root = getRoot(self.context)
+ server_url = str(getView(root, 'absolute_url', self.request))
+ path_start = destination.find(server_url)
+ if path_start == -1:
+ request.response.setStatus(400)
+
+ target = destination[len(server_url):]
+ target = target.split('/')
+ target_path = '/'.join(target[:-1])
+ obj_name = target[-1]
+ dest = traverse(root, target_path)
+
+ copier = queryAdapter(self.context, IObjectCopier, None)
+ if copier is None:
+ request.response.setStatus(403)
+ copier.copyTo(dest, obj_name)
+ request.response.setStatus(201)
return ''