summaryrefslogtreecommitdiff
path: root/addons/document_webdav/nodes.py
diff options
context:
space:
mode:
authorP. Christeas <p_christ@hol.gr>2010-10-12 13:40:20 +0300
committerP. Christeas <p_christ@hol.gr>2010-10-12 13:40:20 +0300
commitf842ccc1ec3beba28238f5027d2c80d23c98e335 (patch)
tree64217d248a72ed79ffe237ab8a57109e6a93ad66 /addons/document_webdav/nodes.py
parent1fe7eb3e8f1454b5846e4e0f432d513813030300 (diff)
Doc webdav: context for DAV properties, dynamic folders
bzr revid: p_christ@hol.gr-20101012104020-izmzgobc2kbxb2cj
Diffstat (limited to 'addons/document_webdav/nodes.py')
-rw-r--r--addons/document_webdav/nodes.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/addons/document_webdav/nodes.py b/addons/document_webdav/nodes.py
index b9483b7b221..0a45b227095 100644
--- a/addons/document_webdav/nodes.py
+++ b/addons/document_webdav/nodes.py
@@ -24,6 +24,19 @@ from document import nodes
from tools.safe_eval import safe_eval as eval
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):
return self.uuser
@@ -53,6 +66,9 @@ class node_acl_mixin(object):
uid = self.context.uid
ctx = self.context.context.copy()
ctx.update(self.dctx)
+ # Not really needed because we don't do eval here:
+ # ctx.update({'uid': uid, 'dbname': self.context.dbname })
+ # dict_filter(self.context.extra_ctx, ['username', 'groupname', 'webdav_path'], ctx)
sdomain = [(prop_ref_field, '=', False),]
if res_id:
sdomain = ['|', (prop_ref_field, '=', res_id)] + sdomain
@@ -88,6 +104,9 @@ class node_acl_mixin(object):
uid = self.context.uid
ctx = self.context.context.copy()
ctx.update(self.dctx)
+ ctx.update({'uid': uid, 'dbname': self.context.dbname })
+ ctx['node_classname'] = "%s.%s" % (self.__class__.__module__, self.__class__.__name__)
+ dict_filter(self.context.extra_ctx, ['username', 'groupname', 'webdav_path'], ctx)
sdomain = [(prop_ref_field, '=', False),('namespace', '=', ns), ('name','=', prop)]
if res_id:
sdomain = ['|', (prop_ref_field, '=', res_id)] + sdomain
@@ -197,6 +216,11 @@ class node_res_dir(node_acl_mixin, nodes.node_res_dir):
return self._get_dav_eprop_hlpr(cr, ns, prop, nodes.node_res_dir,
'document.webdav.dir.property', 'dir_id', self.dir_id)
+# Some copies, so that this module can replace 'from document import nodes'
+get_node_context = nodes.get_node_context
+node_context = nodes.node_context
+node_class = nodes.node_class
+node_descriptor = nodes.node_descriptor
#eof