diff options
| author | P. Christeas <p_christ@hol.gr> | 2010-06-23 13:54:37 +0300 |
|---|---|---|
| committer | P. Christeas <p_christ@hol.gr> | 2010-06-23 13:54:37 +0300 |
| commit | a26e8ae2eef6af0d33255f1081cfcc978c0c5138 (patch) | |
| tree | 580b536630a72156b0c32f8ddcfb6afb069426b5 /addons/document_webdav/webdav.py | |
| parent | 0be3a0757ca31d9abe8f78f86c3606200d546941 (diff) | |
Doc Webdav: Cleanup code, fix db listing, children paths.
This is a reshape of the code, since the porting. While the MultiHttpHandler
will strip the '/webdav' part of the path, the DAV code will try to
generate more paths without it. So, there must be consinstent functions
that will convert (at mk_prop_response and mk_propname_response) to the
full path or back. Also, only have one function that will strip the
db name from the path, so that we control the auth requirements (for the
purpose of database listings, which shouldn't require authentication).
bzr revid: p_christ@hol.gr-20100623105437-kmy0ccqihu5h9ydp
Diffstat (limited to 'addons/document_webdav/webdav.py')
| -rw-r--r-- | addons/document_webdav/webdav.py | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/addons/document_webdav/webdav.py b/addons/document_webdav/webdav.py index 2406bc10492..e904d2ecfb7 100644 --- a/addons/document_webdav/webdav.py +++ b/addons/document_webdav/webdav.py @@ -3,6 +3,7 @@ # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). +# Copyright (c) 1999 Christian Scholz (ruebe@aachen.heimat.de) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -48,7 +49,9 @@ def mk_prop_response(self, uri, good_props, bad_props, doc): uparts=urlparse.urlparse(uri) fileloc=uparts[2] href=doc.createElement("D:href") - huri=doc.createTextNode(uparts[0]+'://'+'/'.join(uparts[1:2]) + urllib.quote(fileloc)) + davpath = self._dataclass.parent.get_davpath() + hurl = '%s://%s%s%s' % (uparts[0], uparts[1], davpath, urllib.quote(fileloc)) + huri=doc.createTextNode(hurl) href.appendChild(huri) re.appendChild(href) @@ -111,5 +114,45 @@ def mk_prop_response(self, uri, good_props, bad_props, doc): return re +def mk_propname_response(self,uri,propnames,doc): + """ make a new <prop> result element for a PROPNAME request + + This will simply format the propnames list. + propnames should have the format {NS1 : [prop1, prop2, ...], NS2: ...} + + """ + re=doc.createElement("D:response") + + # write href information + uparts=urlparse.urlparse(uri) + fileloc=uparts[2] + href=doc.createElement("D:href") + davpath = self._dataclass.parent.get_davpath() + hurl = '%s://%s%s%s' % (uparts[0], uparts[1], davpath, urllib.quote(fileloc)) + huri=doc.createTextNode(hurl) + href.appendChild(huri) + re.appendChild(href) + + ps=doc.createElement("D:propstat") + nsnum=0 + + for ns,plist in propnames.items(): + # write prop element + pr=doc.createElement("D:prop") + nsp="ns"+str(nsnum) + pr.setAttribute("xmlns:"+nsp,ns) + nsnum=nsnum+1 + + # write propertynames + for p in plist: + pe=doc.createElement(nsp+":"+p) + pr.appendChild(pe) + + ps.appendChild(pr) + re.appendChild(ps) + + return re + PROPFIND.mk_prop_response = mk_prop_response +PROPFIND.mk_propname_response = mk_propname_response |
