diff --git a/addons/document_webdav/dav_fs.py b/addons/document_webdav/dav_fs.py index ea4214b25f8..78812ff8cf5 100644 --- a/addons/document_webdav/dav_fs.py +++ b/addons/document_webdav/dav_fs.py @@ -71,7 +71,7 @@ def _str2time(cre): frac = float(cre[fdot:]) cre = cre[:fdot] return time.mktime(time.strptime(cre,'%Y-%m-%d %H:%M:%S')) + frac - + class openerp_dav_handler(dav_interface): """ This class models a OpenERP interface for the DAV server @@ -101,14 +101,14 @@ class openerp_dav_handler(dav_interface): cr.close() return props - def _try_function(self, funct, args, opname='run function', cr=None, - default_exc=DAV_Forbidden): + def _try_function(self, funct, args, opname='run function', cr=None, + default_exc=DAV_Forbidden): """ Try to run a function, and properly convert exceptions to DAV ones. - + @objname the name of the operation being performed @param cr if given, the cursor to close at exceptions """ - + try: return funct(*args) except DAV_Error: @@ -178,7 +178,7 @@ class openerp_dav_handler(dav_interface): else: ret[key] = [] ret[key].extend(val) - + self.parent.log_message('options: %s' % ret) else: ret = opts @@ -210,18 +210,18 @@ class openerp_dav_handler(dav_interface): """Parse the uri and get the dbname and the rest. Db name should be the first component in the unix-like path supplied in uri. - + @param rest_ret Instead of the db_name, return (db_name, rest), where rest is the remaining path @param allow_last If the dbname is the last component in the path, allow it to be resolved. The default False value means we will not attempt to use the db, unless there is more path. - + @return db_name or (dbname, rest) depending on rest_ret, will return dbname=False when component is not found. """ - + uri2 = self.uri2local(uri) if uri2.startswith('/'): uri2 = uri2[1:] @@ -345,7 +345,7 @@ class openerp_dav_handler(dav_interface): try: if not dbname: raise DAV_Error, 409 - node = self.uri2object(cr, uid, pool, uri2) + node = self.uri2object(cr, uid, pool, uri2) if not node: raise DAV_NotFound2(uri2) try: @@ -448,7 +448,7 @@ class openerp_dav_handler(dav_interface): if cr: cr.close() def _get_dav_getlastmodified(self,uri): - """ return the last modified date of a resource + """ return the last modified date of a resource """ d=self.get_lastmodified(uri) # format it. Note that we explicitly set the day, month names from @@ -468,7 +468,7 @@ class openerp_dav_handler(dav_interface): node = self.uri2object(cr, uid, pool, uri2) if not node: raise DAV_NotFound2(uri2) - + return _str2time(node.create_date) finally: if cr: cr.close() @@ -538,7 +538,7 @@ class openerp_dav_handler(dav_interface): cr.close() raise DAV_NotFound('Parent folder not found') - self._try_function(dir_node.create_child, (cr, objname, data), + self._try_function(dir_node.create_child, (cr, objname, data), "create %s" % objname, cr=cr) else: self._try_function(node.set_data, (cr, data), "save %s" % objname, cr=cr) diff --git a/addons/document_webdav/webdav.py b/addons/document_webdav/webdav.py index 8758723e232..1502ff204f8 100644 --- a/addons/document_webdav/webdav.py +++ b/addons/document_webdav/webdav.py @@ -30,14 +30,14 @@ import tools super_mk_prop_response = PROPFIND.mk_prop_response -def mk_prop_response(self, uri, good_props, bad_props, doc): - """ make a new result element +def mk_prop_response(self, uri, good_props, bad_props, doc): + """ make a new result element We differ between the good props and the bad ones for each generating an extra -Node (for each error one, that means). - - """ + + """ re=doc.createElement("D:response") # append namespaces to response nsnum=0 @@ -47,7 +47,7 @@ def mk_prop_response(self, uri, good_props, bad_props, doc): for nsname in namespaces: re.setAttribute("xmlns:ns"+str(nsnum),nsname) nsnum=nsnum+1 - + # write href information uparts=urlparse.urlparse(uri) fileloc=uparts[2] @@ -90,7 +90,7 @@ def mk_prop_response(self, uri, good_props, bad_props, doc): pe.appendChild(ve) gp.appendChild(pe) - + ps.appendChild(gp) s=doc.createElement("D:status") t=doc.createTextNode("HTTP/1.1 200 OK") @@ -113,11 +113,11 @@ def mk_prop_response(self, uri, good_props, bad_props, doc): ns_prefix='D:' else: ns_prefix="ns"+str(self.namespaces.index(ns))+":" - + for p in bad_props[ecode][ns]: pe=doc.createElement(ns_prefix+str(p)) bp.appendChild(pe) - + s=doc.createElement("D:status") t=doc.createTextNode(utils.gen_estring(ecode)) s.appendChild(t) @@ -126,10 +126,10 @@ def mk_prop_response(self, uri, good_props, bad_props, doc): # return the new response element return re - + def mk_propname_response(self,uri,propnames,doc): - """ make a new result element for a PROPNAME request + """ make a new result element for a PROPNAME request This will simply format the propnames list. propnames should have the format {NS1 : [prop1, prop2, ...], NS2: ...}