summaryrefslogtreecommitdiff
path: root/addons/document_webdav/webdav.py
diff options
context:
space:
mode:
authorP. Christeas <p_christ@hol.gr>2010-12-07 15:40:41 +0200
committerP. Christeas <p_christ@hol.gr>2010-12-07 15:40:41 +0200
commit6b2c832f5f9cc1667cd50230f8f0a0139d352201 (patch)
tree61e04e42c975e98e93e061bd6c7b2f50e6cfb2cd /addons/document_webdav/webdav.py
parent9a4c99980315d80e2da5a3af9a1d870bde4cf734 (diff)
doc webdav: Implement locking support
This replaces the pseydo-locking of python-webdav library with a real db-based locking. Locks are stored as DAV properties, which will effectively also be listed in the PROPFIND response of the nodes. With locking in place, Office suites can collaborate on documents online. bzr revid: p_christ@hol.gr-20101207134041-8negkvxrbscv7fs7
Diffstat (limited to 'addons/document_webdav/webdav.py')
-rw-r--r--addons/document_webdav/webdav.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/addons/document_webdav/webdav.py b/addons/document_webdav/webdav.py
index 302d8c2a8a7..dd19aeef7d5 100644
--- a/addons/document_webdav/webdav.py
+++ b/addons/document_webdav/webdav.py
@@ -268,6 +268,39 @@ def mk_propname_response(self,uri,propnames,doc):
PROPFIND.mk_prop_response = mk_prop_response
PROPFIND.mk_propname_response = mk_propname_response
+def mk_lock_response(self, uri, props):
+ """ Prepare the data response to a DAV LOCK command
+
+ This function is here, merely to be in the same file as the
+ ones above, that have similar code.
+ """
+ doc = domimpl.createDocument('DAV:', "D:prop", None)
+ ms = doc.documentElement
+ ms.setAttribute("xmlns:D", "DAV:")
+ # ms.tagName = 'D:multistatus'
+ namespaces = []
+ nsnum = 0
+ propgen = Prop2xml(doc, namespaces, nsnum)
+ # write href information
+ uparts=urlparse.urlparse(uri)
+ fileloc=uparts[2]
+ if isinstance(fileloc, unicode):
+ fileloc = fileloc.encode('utf-8')
+ davpath = self.parent.get_davpath()
+ if uparts[0] and uparts[1]:
+ hurl = '%s://%s%s%s' % (uparts[0], uparts[1], davpath, urllib.quote(fileloc))
+ else:
+ # When the request has been relative, we don't have enough data to
+ # reply with absolute url here.
+ hurl = '%s%s' % (davpath, urllib.quote(fileloc))
+
+ props.append( ('lockroot', 'DAV:', ('href', 'DAV:', (hurl))))
+ pld = doc.createElement('D:lockdiscovery')
+ ms.appendChild(pld)
+ propgen._prop_child(pld, 'DAV:', 'activelock', props)
+
+ return doc.toxml(encoding="utf-8")
+
super_create_prop = REPORT.create_prop
def create_prop(self):