doc webdav: switch on the DAV v2 features
authorP. Christeas <p_christ@hol.gr>
Tue, 12 Oct 2010 10:40:35 +0000 (13:40 +0300)
committerP. Christeas <p_christ@hol.gr>
Tue, 12 Oct 2010 10:40:35 +0000 (13:40 +0300)
The underlying python-webdav supports some emulation for lock/unlock, so
try to use that.

bzr revid: p_christ@hol.gr-20101012104035-jffog0w1dco2lo9i

addons/document_webdav/dav_fs.py
addons/document_webdav/nodes.py
addons/document_webdav/webdav_server.py

index 9e04673..07ffeda 100644 (file)
@@ -26,8 +26,6 @@ import os
 import time
 from string import joinfields, split, lower
 
-from service import security
-
 import netsvc
 import urlparse
 
@@ -39,6 +37,8 @@ import urllib
 from DAV.davcmd import copyone, copytree, moveone, movetree, delone, deltree
 from cache import memoize
 from tools import misc
+from tools.dict_tools import dict_merge2
+
 CACHE_SIZE=20000
 
 #hack for urlparse: add webdav in the net protocols
@@ -95,8 +95,7 @@ class openerp_dav_handler(dav_interface):
             return props
         node = self.uri2object(cr, uid, pool, uri2)
         if node:
-            props = props.copy()
-            props.update(node.get_dav_props(cr))
+            props = dict_merge2(props, node.get_dav_props(cr))
         cr.close()
         return props
 
@@ -133,11 +132,11 @@ class openerp_dav_handler(dav_interface):
             self.parent.log_message("Exc: %s",traceback.format_exc())
             raise default_exc("Operation failed")
 
-    def _get_dav_lockdiscovery(self, uri):
-        raise DAV_NotFound
+    #def _get_dav_lockdiscovery(self, uri):
+    #    raise DAV_NotFound
 
-    def _get_dav_supportedlock(self, uri):
-        raise DAV_NotFound
+    #def A_get_dav_supportedlock(self, uri):
+    #    raise DAV_NotFound
 
     def match_prop(self, uri, match, ns, propname):
         if self.M_NS.has_key(ns):
@@ -293,8 +292,8 @@ class openerp_dav_handler(dav_interface):
             else:
                 fp = node.full_path()
                 if fp and len(fp):
-                    self.parent.log_message('childs: @%s' % fp)
                     fp = '/'.join(fp)
+                    self.parent.log_message('childs for: %s' % fp)
                 else:
                     fp = None
                 domain = None
index 0a45b22..67dc9fd 100644 (file)
 
 from document import nodes
 from tools.safe_eval import safe_eval as eval
+from tools.dict_tools import dict_filter
 import urllib
 
-def dict_filter(srcdic, keys, res=None):
-    ''' Return a copy of srcdic that has only keys set.
-    If any of keys are missing from srcdic, the result won't have them, 
-    either.
-    @param res If given, result will be updated there, instead of a new dict.
-    '''
-    if res is None:
-        res = {}
-    for k in keys:
-        if k in srcdic:
-            res[k] = srcdic[k]
-    return res
     
 class node_acl_mixin(object):
     def _get_dav_owner(self, cr):
index c86cde2..7e4bb69 100644 (file)
@@ -57,7 +57,7 @@ def OpenDAVConfig(**kw):
 class DAVHandler(HttpOptions, FixSendError, DAVRequestHandler):
     verbose = False
     protocol_version = 'HTTP/1.1'
-    _HTTP_OPTIONS= { 'DAV' : ['1',],
+    _HTTP_OPTIONS= { 'DAV' : ['1', '2'],
                     'Allow' : [ 'GET', 'HEAD', 'COPY', 'MOVE', 'POST', 'PUT',
                             'PROPFIND', 'PROPPATCH', 'OPTIONS', 'MKCOL',
                             'DELETE', 'TRACE', 'REPORT', ]
@@ -265,8 +265,7 @@ try:
         handler.debug = config.get_misc('webdav','debug',True)
         _dc = { 'verbose' : verbose,
                 'directory' : directory,
-                'lockemulation' : False,
-
+                'lockemulation' : True,
                 }
 
         conf = OpenDAVConfig(**_dc)