summaryrefslogtreecommitdiff
path: root/addons/document_webdav/webdav.py
diff options
context:
space:
mode:
authorP. Christeas <p_christ@hol.gr>2010-10-12 13:40:29 +0300
committerP. Christeas <p_christ@hol.gr>2010-10-12 13:40:29 +0300
commitf4bc8371430aa5f0fec2a1d52fda558e6ba0e3d0 (patch)
tree1d0bdc40308efc8339c6d45ff0febaf1ca51421c /addons/document_webdav/webdav.py
parentf1ccc3a4e203fc255cf1450684b9f601a2ac7027 (diff)
Doc webdav: enhance the property notation structure
When DAV-aware nodes want to return properties, they might need to have xml attributes or single instances of sub-elements. Example: return ('aprop', 'D:', ('foo', 'D:', None, { 'name': 'bar'})) will result in xml: <D:prop> <D:aprop><D:foo name="bar"/></D:aprop> </D:prop> bzr revid: p_christ@hol.gr-20101012104029-gq6hhjki4i52n8qh
Diffstat (limited to 'addons/document_webdav/webdav.py')
-rw-r--r--addons/document_webdav/webdav.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/addons/document_webdav/webdav.py b/addons/document_webdav/webdav.py
index 6b24198e320..86fd8cd9e71 100644
--- a/addons/document_webdav/webdav.py
+++ b/addons/document_webdav/webdav.py
@@ -67,6 +67,8 @@ def mk_prop_response(self, uri, good_props, bad_props, doc):
string: text node
tuple ('elem', 'ns') for empty sub-node <ns:elem />
tuple ('elem', 'ns', sub-elems) for sub-node with elements
+ tuple ('elem', 'ns', sub-elems, {attrs}) for sub-node with
+ optional elements and attributes
list, of above tuples
"""
if ns == 'DAV:':
@@ -108,14 +110,18 @@ def mk_prop_response(self, uri, good_props, bad_props, doc):
ve=doc.createElement(ns_prefix+v[0])
if need_ns:
ve.setAttribute("xmlns:ns"+str(nsnum), v[1])
- if len(v) > 2:
- if isinstance(v[2], list):
+ if len(v) > 2 and v[2] is not None:
+ if isinstance(v[2], (list, tuple)):
# support nested elements like:
# ( 'elem', 'ns:', [('sub-elem1', 'ns1'), ...]
_prop_elem_child(ve, v[1], v[2], ns_prefix)
else:
vt =doc.createTextNode(tools.ustr(v[2]))
ve.appendChild(vt)
+ if len(v) > 3 and v[3]:
+ assert isinstance(v[3], dict)
+ for ak, av in v[3].items():
+ ve.setAttribute(ak, av)
pnode.appendChild(ve)
else:
ve=doc.createTextNode(tools.ustr(v))