Document: cleanup nodes.py, let node_res_dir be overriden.
bzr revid: p_christ@hol.gr-20101012103945-1ziw8331h4wpvp6t
This commit is contained in:
parent
034a4166c9
commit
4eab25baf3
|
@ -281,6 +281,8 @@ class node_class(object):
|
|||
def get_dav_props(self, cr):
|
||||
""" If this class has special behaviour for GroupDAV etc, export
|
||||
its capabilities """
|
||||
# This fn is placed here rather than WebDAV, because we want the
|
||||
# baseclass methods to apply to all node subclasses
|
||||
return self.DAV_PROPS or {}
|
||||
|
||||
def match_dav_eprop(self, cr, match, ns, prop):
|
||||
|
@ -460,9 +462,6 @@ class node_database(node_class):
|
|||
def _get_ttag(self,cr):
|
||||
return 'db-%s' % cr.dbname
|
||||
|
||||
def get_dav_resourcetype(self, cr):
|
||||
return ('collection', 'DAV:')
|
||||
|
||||
def mkdosname(company_name, default='noname'):
|
||||
""" convert a string to a dos-like name"""
|
||||
if not company_name:
|
||||
|
@ -502,7 +501,7 @@ class node_dir(node_database):
|
|||
for dfld in dirr.dctx_ids:
|
||||
try:
|
||||
self.dctx['dctx_' + dfld.field] = safe_eval(dfld.expr,dc2)
|
||||
except Exception,e:
|
||||
except Exception:
|
||||
print "Cannot eval %s" % dfld.expr
|
||||
print e
|
||||
pass
|
||||
|
@ -667,12 +666,14 @@ class node_dir(node_database):
|
|||
return ret
|
||||
|
||||
class node_res_dir(node_class):
|
||||
""" A special sibling to node_dir, which does only contain dynamically
|
||||
""" A folder containing dynamic folders
|
||||
A special sibling to node_dir, which does only contain dynamically
|
||||
created folders foreach resource in the foreign model.
|
||||
All folders should be of type node_res_obj and merely behave like
|
||||
node_dirs (with limited domain).
|
||||
"""
|
||||
our_type = 'collection'
|
||||
res_obj_class = None
|
||||
def __init__(self, path, parent, context, dirr, dctx=None ):
|
||||
super(node_res_dir,self).__init__(path, parent, context)
|
||||
self.dir_id = dirr.id
|
||||
|
@ -779,17 +780,15 @@ class node_res_dir(node_class):
|
|||
continue
|
||||
# Yes! we can't do better but skip nameless records.
|
||||
|
||||
res.append(node_res_obj(name, self.dir_id, self, self.context, self.res_model, bo))
|
||||
res.append(self.res_obj_class(name, self.dir_id, self, self.context, self.res_model, bo))
|
||||
return res
|
||||
|
||||
def _get_ttag(self,cr):
|
||||
return 'rdir-%d' % self.dir_id
|
||||
|
||||
def get_dav_resourcetype(self, cr):
|
||||
return ('collection', 'DAV:')
|
||||
|
||||
class node_res_obj(node_class):
|
||||
""" A special sibling to node_dir, which does only contain dynamically
|
||||
""" A dynamically created folder.
|
||||
A special sibling to node_dir, which does only contain dynamically
|
||||
created folders foreach resource in the foreign model.
|
||||
All folders should be of type node_res_obj and merely behave like
|
||||
node_dirs (with limited domain).
|
||||
|
@ -825,7 +824,7 @@ class node_res_obj(node_class):
|
|||
for fld,expr in self.dctx_dict.items():
|
||||
try:
|
||||
self.dctx[fld] = safe_eval(expr, dc2)
|
||||
except Exception,e:
|
||||
except Exception:
|
||||
print "Cannot eval %s for %s" % (expr, fld)
|
||||
print e
|
||||
pass
|
||||
|
@ -884,6 +883,7 @@ class node_res_obj(node_class):
|
|||
return res
|
||||
|
||||
def get_dav_props(self, cr):
|
||||
# Deprecated! (but document_ics must be cleaned, first)
|
||||
res = {}
|
||||
cntobj = self.context._dirobj.pool.get('document.directory.content')
|
||||
uid = self.context.uid
|
||||
|
@ -897,6 +897,7 @@ class node_res_obj(node_class):
|
|||
return res
|
||||
|
||||
def get_dav_eprop(self, cr, ns, prop):
|
||||
# Deprecated!
|
||||
if ns != 'http://groupdav.org/' or prop != 'resourcetype':
|
||||
logger.warning("Who asked for %s:%s?" % (ns, prop))
|
||||
return None
|
||||
|
@ -943,17 +944,20 @@ class node_res_obj(node_class):
|
|||
if not res_name:
|
||||
continue
|
||||
# TODO Revise
|
||||
res.append(node_res_obj(res_name, self.dir_id, self, self.context, self.res_model, res_bo = bo))
|
||||
klass = self.__class__
|
||||
res.append(klass(res_name, self.dir_id, self, self.context, self.res_model, res_bo = bo))
|
||||
|
||||
|
||||
where2 = where + [('parent_id','=',self.dir_id) ]
|
||||
ids = dirobj.search(cr, uid, where2, context=ctx)
|
||||
for dirr in dirobj.browse(cr, uid, ids, context=ctx):
|
||||
if dirr.type == 'directory':
|
||||
res.append(node_res_obj(dirr.name, dirr.id, self, self.context, self.res_model, res_bo = None, res_id = self.res_id))
|
||||
klass = self.__class__
|
||||
res.append(klass(dirr.name, dirr.id, self, self.context, self.res_model, res_bo = None, res_id = self.res_id))
|
||||
elif dirr.type == 'ressource':
|
||||
# child resources can be controlled by properly set dctx
|
||||
res.append(node_res_dir(dirr.name,self,self.context, dirr, {'active_id': self.res_id}))
|
||||
klass = dirr.get_node_class(dirr, context=ctx)
|
||||
res.append(klass(dirr.name,self,self.context, dirr, {'active_id': self.res_id}))
|
||||
|
||||
fil_obj = dirobj.pool.get('ir.attachment')
|
||||
if self.res_find_all:
|
||||
|
@ -976,9 +980,11 @@ class node_res_obj(node_class):
|
|||
dirids = dirids + dirobj.search(cr,uid, where5)
|
||||
for dirr in dirobj.browse(cr, uid, dirids, context=ctx):
|
||||
if dirr.type == 'directory' and not dirr.parent_id:
|
||||
res.append(node_res_obj(dirr.name, dirr.id, self, self.context, self.res_model, res_bo = None, res_id = self.res_id))
|
||||
klass = self.__class__
|
||||
res.append(klass(dirr.name, dirr.id, self, self.context, self.res_model, res_bo = None, res_id = self.res_id))
|
||||
if dirr.type == 'ressource':
|
||||
res.append(node_res_dir(dirr.name, self, self.context, dirr, {'active_id': self.res_id}))
|
||||
klass = dirr.get_node_class(dirr, context=ctx)
|
||||
res.append(klass(dirr.name, self, self.context, dirr, {'active_id': self.res_id}))
|
||||
return res
|
||||
|
||||
def create_child_collection(self, cr, objname):
|
||||
|
@ -1044,8 +1050,7 @@ class node_res_obj(node_class):
|
|||
def _get_ttag(self,cr):
|
||||
return 'rodir-%d-%d' % (self.dir_id, self.res_id)
|
||||
|
||||
def get_dav_resourcetype(self, cr):
|
||||
return ('collection', 'DAV:')
|
||||
node_res_dir.res_obj_class = node_res_obj
|
||||
|
||||
class node_file(node_class):
|
||||
our_type = 'file'
|
||||
|
@ -1181,9 +1186,6 @@ class node_file(node_class):
|
|||
def _get_ttag(self,cr):
|
||||
return 'file-%d' % self.file_id
|
||||
|
||||
def get_dav_resourcetype(self, cr):
|
||||
return ''
|
||||
|
||||
def move_to(self, cr, ndir_node, new_name=False, fil_obj=None, ndir_obj=None, in_write=False):
|
||||
if ndir_node and ndir_node.context != self.context:
|
||||
raise NotImplementedError("Cannot move files between contexts")
|
||||
|
@ -1380,3 +1382,5 @@ class nodefd_content(StringIO, node_descriptor):
|
|||
finally:
|
||||
cr.close()
|
||||
StringIO.close(self)
|
||||
|
||||
#eof
|
Loading…
Reference in New Issue