diff --git a/addons/caldav/caldav_node.py b/addons/caldav/caldav_node.py index e974f7c55c0..2ddd5ffa49e 100644 --- a/addons/caldav/caldav_node.py +++ b/addons/caldav/caldav_node.py @@ -260,22 +260,9 @@ class node_calendar(nodes.node_class): _log.debug("Unknown calendar-query element: %s", filter_child.localName) return res elif filters.localName == 'calendar-multiget': - names = [] - for filter_child in filters.childNodes: - if filter_child.nodeType == filter_child.TEXT_NODE: - continue - if filter_child.localName == 'href': - if not filter_child.firstChild: - continue - uri = filter_child.firstChild.data - caluri = uri.split('/') - if len(caluri): - caluri = caluri[-2] - if caluri not in names : names.append(caluri) - else: - _log.debug("Unknonwn multiget element: %s", filter_child.localName) - res = [('name','in',names)] - return res + # this is not the place to process, as it wouldn't support multi-level + # hrefs. So, the code is moved to document_webdav/dav_fs.py + pass else: _log.debug("Unknown element in REPORT: %s", filters.localName) return res 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