Document, DAV: fix propfind/propname code
Several small fixes for the DAV responses, so that we are more conforming to the protocol. Also fix multiple namespaces, getctag and (as always) whitespace bzr revid: p_christ@hol.gr-20100729133937-z6ctpn92w6mz7r9k
This commit is contained in:
parent
449da75e4e
commit
e78571ac67
|
@ -26,15 +26,16 @@ import urlparse
|
|||
urlparse.uses_netloc.append('caldav')
|
||||
urlparse.uses_netloc.append('caldavs')
|
||||
super_mk_prop_response = webdav.mk_prop_response
|
||||
def mk_prop_response(self,uri,good_props,bad_props,doc):
|
||||
res = super_mk_prop_response(self, uri,good_props,bad_props,doc)
|
||||
uris = uri.split('/')
|
||||
calendar = False
|
||||
|
||||
def mk_prop_response(self,uri,good_props,bad_props,doc):
|
||||
res = super_mk_prop_response(self, uri,good_props,bad_props,doc)
|
||||
uris = uri.split('/')
|
||||
calendar = False
|
||||
if 'http://calendarserver.org/ns/' in good_props or 'http://calendarserver.org/ns/' in bad_props:
|
||||
calendar = True
|
||||
if calendar:
|
||||
ad = doc.createElement('calendar')
|
||||
ad.setAttribute('xmlns', 'urn:ietf:params:xml:ns:caldav')
|
||||
ad.setAttribute('xmlns', 'urn:ietf:params:xml:ns:caldav')
|
||||
cols = res.getElementsByTagName('D:collection')
|
||||
if cols:
|
||||
cols[0].parentNode.appendChild(ad)
|
||||
|
|
|
@ -53,7 +53,7 @@ class node_database(nodes.node_database):
|
|||
|
||||
class node_calendar_collection(nodes.node_dir):
|
||||
DAV_PROPS = {
|
||||
"http://calendarserver.org/ns/" : ('getctag'),
|
||||
"http://calendarserver.org/ns/" : ('getctag',),
|
||||
}
|
||||
DAV_M_NS = {
|
||||
"http://calendarserver.org/ns/" : '_get_dav',
|
||||
|
@ -115,11 +115,10 @@ class node_calendar_collection(nodes.node_dir):
|
|||
result = self.get_etag(cr)
|
||||
return str(result)
|
||||
|
||||
|
||||
class node_calendar(nodes.node_class):
|
||||
our_type = 'collection'
|
||||
DAV_PROPS = {
|
||||
"http://calendarserver.org/ns/" : ('getctag'),
|
||||
"http://calendarserver.org/ns/" : ('getctag',),
|
||||
"urn:ietf:params:xml:ns:caldav" : (
|
||||
'calendar-description',
|
||||
'calendar-data',
|
||||
|
@ -167,12 +166,13 @@ class node_calendar(nodes.node_class):
|
|||
return res
|
||||
|
||||
def get_domain(self, cr, filters):
|
||||
# TODO: doc.
|
||||
res = []
|
||||
dirobj = self.context._dirobj
|
||||
uid = self.context.uid
|
||||
ctx = self.context.context.copy()
|
||||
ctx.update(self.dctx)
|
||||
calendar_obj = dirobj.pool.get('basic.calendar')
|
||||
# dirobj = self.context._dirobj
|
||||
#uid = self.context.uid
|
||||
#ctx = self.context.context.copy()
|
||||
#ctx.update(self.dctx)
|
||||
# calendar_obj = dirobj.pool.get('basic.calendar')
|
||||
if not filters:
|
||||
return res
|
||||
if filters.localName == 'calendar-query':
|
||||
|
|
|
@ -349,6 +349,7 @@ class node_class(object):
|
|||
raise NotImplementedError(repr(self))
|
||||
|
||||
def get_domain(self, cr, filters):
|
||||
# TODO Document
|
||||
return []
|
||||
|
||||
def check_perms(self, perms):
|
||||
|
|
|
@ -65,17 +65,20 @@ def mk_prop_response(self, uri, good_props, bad_props, doc):
|
|||
gp=doc.createElement("D:prop")
|
||||
for ns in good_props.keys():
|
||||
ns_prefix="ns"+str(self.namespaces.index(ns))+":"
|
||||
for p,v in good_props[ns].items():
|
||||
for p,v in good_props[ns].items():
|
||||
if not v:
|
||||
pass
|
||||
continue
|
||||
pe=doc.createElement(ns_prefix+str(p))
|
||||
if hasattr(v, '__class__') and v.__class__.__name__ == 'Element':
|
||||
pe.appendChild(v)
|
||||
else:
|
||||
if p=="resourcetype":
|
||||
if v==1:
|
||||
if ns == 'DAV:' and p=="resourcetype":
|
||||
if v == 1:
|
||||
ve=doc.createElement("D:collection")
|
||||
pe.appendChild(ve)
|
||||
elif isinstance(v,tuple) and v[1] == ns:
|
||||
ve=doc.createElement(ns_prefix+v[0])
|
||||
pe.appendChild(ve)
|
||||
else:
|
||||
ve=doc.createTextNode(tools.ustr(v))
|
||||
pe.appendChild(ve)
|
||||
|
@ -147,12 +150,13 @@ def mk_propname_response(self,uri,propnames,doc):
|
|||
pr.setAttribute("xmlns:"+nsp,ns)
|
||||
nsnum=nsnum+1
|
||||
|
||||
# write propertynames
|
||||
for p in plist:
|
||||
pe=doc.createElement(nsp+":"+p)
|
||||
pr.appendChild(pe)
|
||||
# write propertynames
|
||||
for p in plist:
|
||||
pe=doc.createElement(nsp+":"+p)
|
||||
pr.appendChild(pe)
|
||||
|
||||
ps.appendChild(pr)
|
||||
|
||||
ps.appendChild(pr)
|
||||
re.appendChild(ps)
|
||||
|
||||
return re
|
||||
|
|
Loading…
Reference in New Issue