doc webdav: initial override of nodes.py
authorP. Christeas <p_christ@hol.gr>
Tue, 12 Oct 2010 10:38:58 +0000 (13:38 +0300)
committerP. Christeas <p_christ@hol.gr>
Tue, 12 Oct 2010 10:38:58 +0000 (13:38 +0300)
bzr revid: p_christ@hol.gr-20101012103858-hykw2g2ezbwaobmn

addons/document_webdav/__init__.py
addons/document_webdav/dav_fs.py
addons/document_webdav/document_webdav.py [new file with mode: 0644]
addons/document_webdav/nodes.py [new file with mode: 0644]

index 6931266..ac417e1 100644 (file)
@@ -21,3 +21,7 @@
 
 import webdav
 import webdav_server
+
+import document_webdav
+
+#eof
\ No newline at end of file
index 8cd00da..9e04673 100644 (file)
@@ -37,7 +37,6 @@ from DAV.iface import *
 import urllib
 
 from DAV.davcmd import copyone, copytree, moveone, movetree, delone, deltree
-from document.nodes import node_res_dir, node_res_obj
 from cache import memoize
 from tools import misc
 CACHE_SIZE=20000
diff --git a/addons/document_webdav/document_webdav.py b/addons/document_webdav/document_webdav.py
new file mode 100644 (file)
index 0000000..2db183e
--- /dev/null
@@ -0,0 +1,47 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2010 Tiny SPRL (<http://tiny.be>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from osv import osv, fields
+import nodes
+
+class document_davdir(osv.osv):
+    _inherit = 'document.directory'
+
+    def get_node_class(self, cr, uid, ids, dbro=None, context=None):
+        # Note: in this function, nodes come from document_webdav/nodes.py !
+        if dbro is None:
+            dbro = self.browse(cr, uid, ids, context=context)
+
+        if dbro.type == 'directory':
+            return nodes.node_dir
+        elif dbro.type == 'ressource':
+            assert not dbro.ressource_parent_type_id, \
+                "resource and parent_id at #%d: %r" % (dbro.id, dbro.ressource_parent_type_id)
+            return nodes.node_res_dir
+        else:
+            raise ValueError("dir node for %s type", dbro.type)
+
+    def _prepare_context(self, cr, uid, nctx, context):
+        nctx.node_file_class = nodes.node_file
+        return
+
+document_davdir()
+#eof
\ No newline at end of file
diff --git a/addons/document_webdav/nodes.py b/addons/document_webdav/nodes.py
new file mode 100644 (file)
index 0000000..6e9d85a
--- /dev/null
@@ -0,0 +1,57 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2010 Tiny SPRL (<http://tiny.be>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+
+from document import nodes
+
+class node_acl_mixin(object):
+    def _get_dav_owner(self, cr):
+        return self.uuser
+
+    def _get_dav_group(self, cr):
+        return self.ugroup
+        
+    def _get_dav_supported_privilege_set(self, cr):
+        return '' # TODO
+    
+    def _get_dav_current_user_privilege_set(self, cr):
+        return '' # TODO
+
+class node_dir(node_acl_mixin, nodes.node_dir):
+    DAV_PROPS = { "DAV:": ('owner', 'group', 
+                            'supported-privilege-set', 
+                            'current-user-privilege-set'), 
+                }
+    DAV_M_NS = { "DAV:" : '_get_dav',}
+    http_options = { 'DAV': ['access-control',] }
+
+
+class node_file(node_acl_mixin, nodes.node_file):
+    DAV_PROPS = { "DAV:": ('owner', 'group', 
+                            'supported-privilege-set', 
+                            'current-user-privilege-set'), 
+                }
+    DAV_M_NS = { "DAV:" : '_get_dav',}
+    http_options = { 'DAV': ['access-control', ] }
+    pass
+
+
+#eof