diff options
| author | P. Christeas <p_christ@hol.gr> | 2010-10-12 13:38:56 +0300 |
|---|---|---|
| committer | P. Christeas <p_christ@hol.gr> | 2010-10-12 13:38:56 +0300 |
| commit | 402d407b2c3f630ca57d31f72b48ed397fec1119 (patch) | |
| tree | 80d95a4a445664fabb48abead492d3037c8855a9 /addons/document/document_directory.py | |
| parent | 2655d0e091357c7f70dde96f216f59444b8297df (diff) | |
Document: make node classes pluggable (part 1)
Refactor and put hooks in document/nodes so that addons can override
the classes and enhance the node behaviour, per database.
bzr revid: p_christ@hol.gr-20101012103856-j115po98jqff6j02
Diffstat (limited to 'addons/document/document_directory.py')
| -rw-r--r-- | addons/document/document_directory.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/addons/document/document_directory.py b/addons/document/document_directory.py index 3486359f183..0c208ad04b7 100644 --- a/addons/document/document_directory.py +++ b/addons/document/document_directory.py @@ -175,6 +175,38 @@ class document_directory(osv.osv): return nodes.get_node_context(cr, uid, context).get_uri(cr, uri) + def get_node_class(self, cr, uid, ids, dbro=None, context=None): + """Retrieve the class of nodes for this directory + + This function can be overriden by inherited classes ;) + @param dbro The browse object, if caller already has it + """ + 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): + """ Fill nctx with properties for this database + @param nctx instance of nodes.node_context, to be filled + @param context ORM context (dict) for us + + Note that this function is called *without* a list of ids, + it should behave the same for the whole database (based on the + ORM instance of document.directory). + + Some databases may override this and attach properties to the + node_context. See WebDAV, CalDAV. + """ + return + def get_dir_permissions(self, cr, uid, ids ): """Check what permission user 'uid' has on directory 'id' """ |
