[Zope-CVS] CVS: Packages/Moztop/moztopsupport/dav - views.py:1.1 adapters.py:1.2 configure.zcml:1.2 propfind.py:1.2
Sidnei da Silva
sidnei@x3ng.com.br
Mon, 24 Mar 2003 10:38:53 -0500
Update of /cvs-repository/Packages/Moztop/moztopsupport/dav
In directory cvs.zope.org:/tmp/cvs-serv25843/dav
Modified Files:
adapters.py configure.zcml propfind.py
Added Files:
views.py
Log Message:
First steps on implementing dav source support. Its rather messy, but i will clean it up later today
=== Added File Packages/Moztop/moztopsupport/dav/views.py ===
from zope.publisher.browser import BrowserView
from zope.component import getView
from moztopsupport.dav.interfaces import IDAVSource
class ZPTDAVSource(BrowserView):
__implements__ = IDAVSource
def __str__(self):
resource_url = str(getView(self.context, 'absolute_url', self.request))
source_url = '%s/getSource' % resource_url
return self._xml % {'resource_url':resource_url,
'source_url':source_url}
__call__ = __str__
_xml = '''
<D:source>
<D:link>
<D:src>%(resource_url)s</D:src>
<D:dst>%(source_url)s</D:dst>
</D:link>
</D:source>
'''
=== Packages/Moztop/moztopsupport/dav/adapters.py 1.1 => 1.2 ===
--- Packages/Moztop/moztopsupport/dav/adapters.py:1.1 Mon Mar 24 06:26:31 2003
+++ Packages/Moztop/moztopsupport/dav/adapters.py Mon Mar 24 10:38:23 2003
@@ -1,8 +1,4 @@
-from moztopsupport.dav.interfaces import IDAVSource, IDAVCreationDate, IDAVDisplayName
-
-class DAVSource:
-
- __implements__ = IDAVSource
+from moztopsupport.dav.interfaces import IDAVCreationDate, IDAVDisplayName
class DAVCreationDate:
=== Packages/Moztop/moztopsupport/dav/configure.zcml 1.1 => 1.2 ===
--- Packages/Moztop/moztopsupport/dav/configure.zcml:1.1 Mon Mar 24 06:26:31 2003
+++ Packages/Moztop/moztopsupport/dav/configure.zcml Mon Mar 24 10:38:23 2003
@@ -1,12 +1,19 @@
-<zopeConfigure xmlns='http://namespaces.zope.org/zope'>
+<zopeConfigure xmlns='http://namespaces.zope.org/zope'
+ xmlns:browser='http://namespaces.zope.org/browser'>
-<view
- for="*"
- name="PROPFIND"
- type="zope.publisher.interfaces.http.IHTTPPresentation"
- factory=".propfind.PROPFIND"
- permission="zope.Public"
- allowed_attributes="PROPFIND"
+ <view for="*"
+ name="PROPFIND"
+ type="zope.publisher.interfaces.http.IHTTPPresentation"
+ factory=".propfind.PROPFIND"
+ permission="zope.Public"
+ allowed_attributes="PROPFIND"
/>
+
+ <browser:page
+ for="zope.app.interfaces.content.IZPTPage"
+ name="D:source"
+ class=".views.ZPTDAVSource
+ permission="zope.ManageContent"
+ />
</zopeConfigure>
=== Packages/Moztop/moztopsupport/dav/propfind.py 1.1 => 1.2 ===
--- Packages/Moztop/moztopsupport/dav/propfind.py:1.1 Mon Mar 24 06:26:31 2003
+++ Packages/Moztop/moztopsupport/dav/propfind.py Mon Mar 24 10:38:23 2003
@@ -15,6 +15,11 @@
"""
__metaclass__ = type
+from xml.dom import minidom
+from zope.component import getAdapter, getView
+
+from moztopsupport.dav.interfaces import IDAVSource
+
class PROPFIND:
"""PROPFIND handler for all objects
"""
@@ -33,6 +38,9 @@
def PROPFIND(self):
request = self.request
content_type = request.getHeader('content-type', '')
+ hostname = request.getHeader('hostname', '')
+ data = request.bodyFile
+ response = ''
if content_type.lower() not in ['text/xml', 'application/xml']:
request.response.setStatus(400)
@@ -46,7 +54,32 @@
self.setDepth(depth)
+ xmldoc = minidom.parse(data)
+ source = xmldoc.getElementsByTagName('D:source')
+ if source:
+ response = str(getView(self.context, 'DAVsource', self.request))
+
+ body = self._buildBody(response)
+ request.response.setBody(body)
request.response.setStatus(207)
return ''
-
+ def _buildBody(self, response):
+ resource_url = str(getView(self.context, 'absolute_url', self.request))
+ return self._xml % ({'resource_url':resource_url,
+ 'response':response})
+
+ _xml = '''
+ <?xml version="1.0" encoding="utf-8" ?>
+ <D:multistatus xmlns:D="DAV:">
+ <D:response>
+ <D:href>%(resource_url)s</D:href>
+ <D:propstat>
+ <D:prop>
+ %(response)s
+ </D:prop>
+ <D:status>HTTP/1.1 200 OK</D:status>
+ </D:propstat>
+ </D:response>
+ </D:multistatus>
+ '''