summaryrefslogtreecommitdiff
path: root/addons/document_webdav
diff options
context:
space:
mode:
authorP. Christeas <p_christ@hol.gr>2010-10-12 13:41:03 +0300
committerP. Christeas <p_christ@hol.gr>2010-10-12 13:41:03 +0300
commitd697bd94e5a860d91ddf3f5ffaa94a4c6f9c5384 (patch)
tree1ebec203161a7a56108f0888aa266d5d7dcf9542 /addons/document_webdav
parent7bd29d41546d0253d136b4a95c075d40947d3b11 (diff)
Doc webdav, caldav: fix support for the calendar-multiget report
This report is a request to fetch multiple calendar entries. The request contains a range of URIs to fetch, which must be processed at the dav_fs.Report level. The report is being called with Depth: 0 , for which the library could not perform an iterator. Hack over it and explictly set Depth:1 in our case. bzr revid: p_christ@hol.gr-20101012104103-eu156146jy4a75af
Diffstat (limited to 'addons/document_webdav')
-rw-r--r--addons/document_webdav/dav_fs.py24
-rw-r--r--addons/document_webdav/webdav.py16
2 files changed, 40 insertions, 0 deletions
diff --git a/addons/document_webdav/dav_fs.py b/addons/document_webdav/dav_fs.py
index 031e8da5a15..7deb18f714c 100644
--- a/addons/document_webdav/dav_fs.py
+++ b/addons/document_webdav/dav_fs.py
@@ -309,12 +309,36 @@ class openerp_dav_handler(dav_interface):
domain = None
if filters:
domain = node.get_domain(cr, filters)
+
+ if hasattr(filters, 'getElementsByTagNameNS'):
+ hrefs = filters.getElementsByTagNameNS('DAV:', 'href')
+ if hrefs:
+ ul = self.parent.davpath + self.uri2local(uri)
+ for hr in hrefs:
+ turi = ''
+ for tx in hr.childNodes:
+ if tx.nodeType == hr.TEXT_NODE:
+ turi += tx.data
+
+ if turi.startswith(ul):
+ result.append( turi[len(self.parent.davpath):])
+ else:
+ self.parent.log_error("ignore href %s because it is not under request path", turi)
+ return result
+ # We don't want to continue with the children found below
+ # Note the exceptions and that 'finally' will close the
+ # cursor
for d in node.children(cr, domain):
self.parent.log_message('child: %s' % d.path)
if fp:
result.append( self.urijoin(dbname,fp,d.path) )
else:
result.append( self.urijoin(dbname,d.path) )
+ except DAV_Error:
+ raise
+ except Exception:
+ self.parent.log_error("cannot get_childs: "+ str(e))
+ raise
finally:
if cr: cr.close()
return result
diff --git a/addons/document_webdav/webdav.py b/addons/document_webdav/webdav.py
index 0a9f4cd1111..484a1054475 100644
--- a/addons/document_webdav/webdav.py
+++ b/addons/document_webdav/webdav.py
@@ -31,6 +31,7 @@ from osv import osv
try:
from DAV import utils
from DAV.propfind import PROPFIND
+ from DAV.report import REPORT
except ImportError:
raise osv.except_osv('PyWebDAV Import Error!','Please install PyWebDAV \
from http://code.google.com/p/pywebdav/downloads/detail?name=PyWebDAV-0.9.4.tar.gz&can=2&q=/')
@@ -257,3 +258,18 @@ def mk_propname_response(self,uri,propnames,doc):
PROPFIND.mk_prop_response = mk_prop_response
PROPFIND.mk_propname_response = mk_propname_response
+super_create_prop = REPORT.create_prop
+
+def create_prop(self):
+ try:
+ if (self.filter is not None) and self._depth == "0":
+ hrefs = self.filter.getElementsByTagNameNS('DAV:', 'href')
+ if hrefs:
+ self._depth = "1"
+ except Exception:
+ pass
+ return super_create_prop(self)
+
+REPORT.create_prop = create_prop
+
+#eof