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
_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
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
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=/')
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