diff options
| author | atp (Open ERP) <atp@tinyerp.co.in> | 2010-06-22 10:45:44 +0530 |
|---|---|---|
| committer | atp (Open ERP) <atp@tinyerp.co.in> | 2010-06-22 10:45:44 +0530 |
| commit | b0efd26edd9f4e2aa75424b787ea46d2be15cd04 (patch) | |
| tree | e78cdb693e62a5c9a17f77a395eec51fb34becbf /addons/document | |
| parent | 46bb1ea51be702758d68a5f69db32c82dbccf9bd (diff) | |
| parent | 2319190c5a20cb8095f85cacca89a33164ba93d7 (diff) | |
[MERGE]: merge with lp:~openerp-dev/openobject-addons/trunk-dev-addons2
bzr revid: atp@tinyerp.co.in-20100622051544-c7hig73zk2at66cy
Diffstat (limited to 'addons/document')
| -rw-r--r-- | addons/document/__openerp__.py | 13 | ||||
| -rw-r--r-- | addons/document/board_document_demo.xml | 17 | ||||
| -rw-r--r-- | addons/document/board_document_view.xml | 114 | ||||
| -rw-r--r-- | addons/document/content_index.py | 10 | ||||
| -rw-r--r-- | addons/document/directory_report.py | 10 | ||||
| -rw-r--r-- | addons/document/document_directory.py | 28 | ||||
| -rw-r--r-- | addons/document/document_storage.py | 2 | ||||
| -rw-r--r-- | addons/document/document_view.xml | 2 | ||||
| -rw-r--r-- | addons/document/nodes.py | 103 | ||||
| -rw-r--r-- | addons/document/test_cindex.py | 9 |
10 files changed, 218 insertions, 90 deletions
diff --git a/addons/document/__openerp__.py b/addons/document/__openerp__.py index 2064ba32375..5e1aa939b54 100644 --- a/addons/document/__openerp__.py +++ b/addons/document/__openerp__.py @@ -27,7 +27,11 @@ 'description': """This is a complete document management system: * User Authentication * Document Indexation :- .pptx and .docx files are not support in windows platform. - + * Dashboard for Document that includes: + * New Files (list) + * Files by Resource Type (graph) + * Files by Partner (graph) + * Files by Month (graph) ATTENTION: - When you install this module in a running company that have already PDF files stored into the database, you will lose them all. @@ -36,7 +40,7 @@ """, 'author': 'Tiny', 'website': 'http://www.openerp.com', - 'depends': ['base', 'process'], + 'depends': ['base', 'process','board'], 'init_xml': [], 'update_xml': [ 'document_view.xml', @@ -44,9 +48,10 @@ 'wizard/document_configuration_view.xml', 'security/document_security.xml', 'security/ir.model.access.csv', - 'report/document_report_view.xml' + 'report/document_report_view.xml', + 'board_document_view.xml', ], - 'demo_xml': [ 'document_demo.xml',], + 'demo_xml': [ 'document_demo.xml','board_document_demo.xml'], 'test': [ 'test/document_test.yml', ], diff --git a/addons/document/board_document_demo.xml b/addons/document/board_document_demo.xml new file mode 100644 index 00000000000..6f8f8ffa39e --- /dev/null +++ b/addons/document/board_document_demo.xml @@ -0,0 +1,17 @@ +<?xml version="1.0"?> +<openerp> + <data noupdate="1"> + + <!-- + Administrator shortcut + Demo user startup menu + --> + <record model="ir.ui.view_sc" id="sc_document_dash"> + <field name="name">Documents dashboard</field> + <field name="user_id" ref="base.user_root"/> + <field name="resource">ir.ui.menu</field> + <field name="sequence">1</field> + <field name="res_id" ref="menu_board_document_manager"/> + </record> + </data> + </openerp> diff --git a/addons/document/board_document_view.xml b/addons/document/board_document_view.xml new file mode 100644 index 00000000000..4d89f96cbfb --- /dev/null +++ b/addons/document/board_document_view.xml @@ -0,0 +1,114 @@ +<?xml version="1.0"?> + <openerp> + <data> + <record model="board.note.type" id="note_document_type"> + <field name="name">Document</field> + </record> + + <record model="ir.ui.view" id="board_document_manager_form"> + <field name="name">board.document.manager.form</field> + <field name="model">board.board</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Document board"> + <hpaned position="100"> + <child1> + <action + string="New Files" + name="%(document.action_view_all_document_tree1)d" + view_mode="tree" + domain="[('name','=',time.strftime('%%Y')),('month','=',time.strftime('%%m'))]"/> + + <action + string="File Size by Month" + name="%(document.action_view_size_month)d" + view_mode="graph,tree"/> + </child1> + <child2> + <action + string="Files by Resource Type" + name="%(document.action_view_document_by_resourcetype_graph)d" + view_mode="graph,tree"/> + + <action + string="Files by Partner" + name="%(document.action_view_files_by_partner)d" + view_mode="graph,tree"/> + </child2> + </hpaned> + </form> + </field> + </record> + + + <record model="ir.actions.act_window" id="open_board_document_manager"> + <field name="name">Document Dashboard</field> + <field name="res_model">board.board</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + + <field name="view_id" ref="board_document_manager_form"/> + </record> + + <menuitem icon="terp-graph" id="base.dashboard" name="Dashboards" sequence="2" parent="base.reporting_menu"/> + <menuitem + name="Document" + id="menu_board_document" + parent="base.dashboard" + groups="document.group_document_manager"/> + + + <menuitem + parent="menu_board_document" + action="open_board_document_manager" + sequence="1" + id="menu_board_document_manager" + icon="terp-graph"/> + + <record model="ir.ui.view" id="board_document_manager_form1"> + <field name="name">board.document.manager.form1</field> + <field name="model">board.board</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Document board"> + <hpaned position="100"> + <child1> + <action + string="Wall of Shame" + name="%(document.action_view_wall)d" + view_mode="tree"/> + + </child1> + <child2> + <action + string="Files by Users" + name="%(document.action_view_user_graph)d" + view_mode="graph,tree"/> + + <action + string="Files by Month" + name="%(document.action_view_files_by_month_graph)d" + view_mode="graph,tree"/> + </child2> + </hpaned> + </form> + </field> + </record> + + + <record model="ir.actions.act_window" id="open_board_document_manager1"> + <field name="name">Statistics by User</field> + <field name="res_model">board.board</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="view_id" ref="board_document_manager_form1"/> + </record> + + <menuitem + parent="menu_board_document" + action="open_board_document_manager1" + sequence="1" + id="menu_board_document_manager1" + icon="terp-graph"/> + </data> + </openerp> diff --git a/addons/document/content_index.py b/addons/document/content_index.py index a13ba35b60a..e7f88834647 100644 --- a/addons/document/content_index.py +++ b/addons/document/content_index.py @@ -27,7 +27,7 @@ class NhException(Exception): from subprocess import Popen, PIPE -class indexer(): +class indexer(object): """ An indexer knows how to parse the content of some file. Typically, one indexer should be instantiated per file @@ -43,7 +43,7 @@ class indexer(): def _getExtensions(self): return [] - def _getDefMime(self,ext): + def _getDefMime(self, ext): """ Return a mimetype for this document type, ideally the closest to the extension ext. """ mts = self._getMimeTypes(); @@ -51,7 +51,7 @@ class indexer(): return mts[0] return None - def indexContent(self,content,filename=None, realfile = None): + def indexContent(self, content, filename=None, realfile = None): """ Use either content or the real file, to index. Some parsers will work better with the actual content, others parse a file easier. Try the @@ -111,7 +111,7 @@ def mime_match(mime, mdict): return (None, None) -class contentIndex(): +class contentIndex(object): __logger = logging.getLogger('addons.document.content_index') def __init__(self): self.mimes = {} @@ -132,7 +132,7 @@ class contentIndex(): if not f: raise Exception("Your indexer should at least suport a mimetype or extension") - def doIndex(self,content, filename=None, content_type=None, realfname = None, debug=False): + def doIndex(self, content, filename=None, content_type=None, realfname = None, debug=False): fobj = None fname = None mime = None diff --git a/addons/document/directory_report.py b/addons/document/directory_report.py index a7a3d80191b..a4cd2f45068 100644 --- a/addons/document/directory_report.py +++ b/addons/document/directory_report.py @@ -35,10 +35,10 @@ class ir_action_report_xml(osv.osv): def _model_get(self, cr, uid, ids, name, arg, context): res = {} model_pool = self.pool.get('ir.model') - for data in self.read(cr,uid,ids,['model']): + for data in self.read(cr, uid, ids, ['model']): model = data.get('model',False) if model: - model_id =model_pool.search(cr,uid,[('model','=',model)]) + model_id =model_pool.search(cr, uid, [('model','=',model)]) if model_id: res[data.get('id')] = model_id[0] else: @@ -51,14 +51,14 @@ class ir_action_report_xml(osv.osv): model_id= args[0][2] if not model_id: return [] - model = self.pool.get('ir.model').read(cr,uid,[model_id])[0]['model'] - report_id = self.search(cr,uid,[('model','=',model)]) + model = self.pool.get('ir.model').read(cr, uid, [model_id])[0]['model'] + report_id = self.search(cr, uid, [('model','=',model)]) if not report_id: return [('id','=','0')] return [('id','in',report_id)] _columns={ - 'model_id' : fields.function(_model_get,fnct_search=_model_search,method=True,string='Model Id'), + 'model_id' : fields.function(_model_get, fnct_search=_model_search, method=True, string='Model Id'), } ir_action_report_xml() diff --git a/addons/document/document_directory.py b/addons/document/document_directory.py index 8c50164701b..75cb2e5098e 100644 --- a/addons/document/document_directory.py +++ b/addons/document/document_directory.py @@ -80,10 +80,10 @@ class document_directory(osv.osv): return False return objid.browse(cr, uid, mid, context=context).res_id - def _get_def_storage(self,cr,uid,context=None): + def _get_def_storage(self, cr, uid, context=None): if context and context.has_key('default_parent_id'): # Use the same storage as the parent.. - diro = self.browse(cr,uid,context['default_parent_id']) + diro = self.browse(cr, uid, context['default_parent_id']) if diro.storage_id: return diro.storage_id.id objid=self.pool.get('ir.model.data') @@ -121,7 +121,7 @@ class document_directory(osv.osv): """ Return the full path to this directory, in a list, root first """ def _parent(dir_id, path): - parent=self.browse(cr,uid,dir_id) + parent=self.browse(cr, uid, dir_id) if parent.parent_id and not parent.ressource_parent_type_id: _parent(parent.parent_id.id,path) path.append(parent.name) @@ -132,12 +132,12 @@ class document_directory(osv.osv): _parent(dir_id, path) return path - def ol_get_resource_path(self,cr,uid,dir_id,res_model,res_id): + def ol_get_resource_path(self, cr, uid, dir_id, res_model, res_id): # this method will be used in process module # to be need test and Improvement if resource dir has parent resource (link resource) path=[] def _parent(dir_id,path): - parent=self.browse(cr,uid,dir_id) + parent=self.browse(cr, uid, dir_id) if parent.parent_id and not parent.ressource_parent_type_id: _parent(parent.parent_id.id,path) path.append(parent.name) @@ -146,10 +146,10 @@ class document_directory(osv.osv): return path directory=self.browse(cr,uid,dir_id) - model_ids=self.pool.get('ir.model').search(cr,uid,[('model','=',res_model)]) + model_ids=self.pool.get('ir.model').search(cr, uid, [('model','=',res_model)]) if directory: _parent(dir_id,path) - path.append(self.pool.get(directory.ressource_type_id.model).browse(cr,uid,res_id).name) + path.append(self.pool.get(directory.ressource_type_id.model).browse(cr, uid, res_id).name) #user=self.pool.get('res.users').browse(cr,uid,uid) #return "ftp://%s:%s@localhost:%s/%s/%s"%(user.login,user.password,config.get('ftp_server_port',8021),cr.dbname,'/'.join(path)) # No way we will return the password! @@ -197,7 +197,7 @@ class document_directory(osv.osv): context['lang'] = lang try: #just instrumentation - return nodes.get_node_context(cr, uid, context).get_uri(cr,uri) + return nodes.get_node_context(cr, uid, context).get_uri(cr, uri) except Exception,e: print "exception: ",e raise @@ -237,15 +237,15 @@ class document_directory(osv.osv): default ={} name = self.read(cr, uid, [id])[0]['name'] default.update({'name': name+ " (copy)"}) - return super(document_directory,self).copy(cr,uid,id,default,context) + return super(document_directory,self).copy(cr, uid, id, default, context) - def _check_duplication(self, cr, uid,vals,ids=[],op='create'): + def _check_duplication(self, cr, uid, vals, ids=[], op='create'): name=vals.get('name',False) parent_id=vals.get('parent_id',False) ressource_parent_type_id=vals.get('ressource_parent_type_id',False) ressource_id=vals.get('ressource_id',0) if op=='write': - for directory in self.browse(cr,uid,ids): + for directory in self.browse(cr, uid, ids): if not name: name=directory.name if not parent_id: @@ -263,12 +263,12 @@ class document_directory(osv.osv): return False return True def write(self, cr, uid, ids, vals, context=None): - if not self._check_duplication(cr,uid,vals,ids,op='write'): + if not self._check_duplication(cr, uid, vals, ids, op='write'): raise osv.except_osv(_('ValidateError'), _('Directory name must be unique!')) - return super(document_directory,self).write(cr,uid,ids,vals,context=context) + return super(document_directory,self).write(cr, uid, ids, vals, context=context) def create(self, cr, uid, vals, context=None): - if not self._check_duplication(cr,uid,vals): + if not self._check_duplication(cr, uid, vals): raise osv.except_osv(_('ValidateError'), _('Directory name must be unique!')) if vals.get('name',False) and (vals.get('name').find('/')+1 or vals.get('name').find('@')+1 or vals.get('name').find('$')+1 or vals.get('name').find('#')+1) : raise osv.except_osv(_('ValidateError'), _('Directory name contains special characters!')) diff --git a/addons/document/document_storage.py b/addons/document/document_storage.py index ac9925c1635..e319ed12f67 100644 --- a/addons/document/document_storage.py +++ b/addons/document/document_storage.py @@ -311,7 +311,7 @@ class document_storage(osv.osv): if not fname: return None path = storage_bo.path - return ( storage_bo.id, 'file', os.path.join(path,fname)) + return ( storage_bo.id, 'file', os.path.join(path, fname)) else: raise TypeError("No %s storage" % boo.type) diff --git a/addons/document/document_view.xml b/addons/document/document_view.xml index 3f1e09ae76c..aa047c6fe54 100644 --- a/addons/document/document_view.xml +++ b/addons/document/document_view.xml @@ -3,7 +3,7 @@ <!--<menuitem name="Document Management" icon="terp-stock" id="menu_document"/> <menuitem name="Document Configuration" id="menu_document_configuration" parent="menu_document"/>--> - <menuitem name="Knowledge" icon="terp-stock" id="base.menu_document" sequence="4" groups="base.group_user"/> + <menuitem name="Knowledge" icon="terp-stock" id="base.menu_document" sequence="19" groups="base.group_user"/> <menuitem name="Configuration" id="base.menu_document_configuration" parent="base.menu_document" sequence="50"/> <menuitem name="Document Management" id="menu_document_management_configuration" parent="base.menu_document_configuration" sequence="1"/> diff --git a/addons/document/nodes.py b/addons/document/nodes.py index d0815ef9c74..df1878ad798 100644 --- a/addons/document/nodes.py +++ b/addons/document/nodes.py @@ -42,7 +42,7 @@ import time # def get_node_context(cr, uid, context): - return node_context(cr,uid,context) + return node_context(cr, uid, context) class node_context(object): """ This is the root node, representing access to some particular @@ -60,7 +60,7 @@ class node_context(object): def get_uri(self, cr, uri): """ Although this fn passes back to doc.dir, it is needed since it is a potential caching point """ - (ndir, duri) = self._dirobj._locate_child(cr,self.uid, self.rootdir,uri, None, self) + (ndir, duri) = self._dirobj._locate_child(cr, self.uid, self.rootdir, uri, None, self) while duri: ndir = ndir.child(cr, duri[0]) if not ndir: @@ -158,7 +158,7 @@ class node_class(object): return True return False - def get_dav_eprop(self,cr,ns,prop): + def get_dav_eprop(self, cr, ns, prop): return None def rm(self, cr): @@ -205,19 +205,19 @@ class node_database(node_class): where2 = where + domain + [('type', '=', 'directory')] ids = dirobj.search(cr, uid, where2, context=ctx) res = [] - for dirr in dirobj.browse(cr,uid,ids,context=ctx): - res.append(node_dir(dirr.name,self,self.context,dirr)) + for dirr in dirobj.browse(cr, uid, ids, context=ctx): + res.append(node_dir(dirr.name, self, self.context,dirr)) where2 = where + domain + [('type', '=', 'ressource'), ('ressource_parent_type_id','=',False)] ids = dirobj.search(cr, uid, where2, context=ctx) - for dirr in dirobj.browse(cr,uid,ids,context=ctx): - res.append(node_res_dir(dirr.name,self,self.context,dirr)) + for dirr in dirobj.browse(cr, uid, ids, context=ctx): + res.append(node_res_dir(dirr.name, self, self.context, dirr)) fil_obj = dirobj.pool.get('ir.attachment') - ids = fil_obj.search(cr,uid,where,context=ctx) + ids = fil_obj.search(cr, uid, where, context=ctx) if ids: - for fil in fil_obj.browse(cr,uid,ids,context=ctx): - res.append(node_file(fil.name,self,self.context,fil)) + for fil in fil_obj.browse(cr, uid, ids, context=ctx): + res.append(node_file(fil.name, self, self.context, fil)) return res def _file_get(self,cr, nodename=False, directory_id=False): @@ -241,7 +241,7 @@ class node_database(node_class): class node_dir(node_database): our_type = 'collection' - def __init__(self,path, parent, context, dirr, dctx=None): + def __init__(self, path, parent, context, dirr, dctx=None): super(node_dir,self).__init__(path, parent,context) self.dir_id = dirr and dirr.id or False #todo: more info from dirr @@ -269,7 +269,7 @@ class node_dir(node_database): pass - def get_data(self,cr): + def get_data(self, cr): res = '' for child in self.children(cr): res += child.get_data(cr) @@ -277,7 +277,7 @@ class node_dir(node_database): - def _file_get(self,cr, nodename=False): + def _file_get(self, cr, nodename=False): return super(node_dir,self)._file_get(cr, nodename, self.dir_id) @@ -320,7 +320,7 @@ class node_dir(node_database): return dirobj.create(cr, uid, val) - def create_child(self,cr,path,data): + def create_child(self, cr, path, data): """ API function to create a child file object and node Return the node_* created """ @@ -336,10 +336,10 @@ class node_dir(node_database): # Datas are not set here } - fil_id = fil_obj.create(cr,uid, val, context=ctx) - fil = fil_obj.browse(cr,uid,fil_id,context=ctx) - fnode = node_file(path,self,self.context,fil) - fnode.set_data(cr,data,fil) + fil_id = fil_obj.create(cr, uid, val, context=ctx) + fil = fil_obj.browse(cr, uid, fil_id, context=ctx) + fnode = node_file(path, self, self.context, fil) + fnode.set_data(cr, data, fil) return fnode def get_etag(self, cr): @@ -365,8 +365,8 @@ class node_res_dir(node_class): node_dirs (with limited domain). """ our_type = 'collection' - def __init__(self,path, parent, context, dirr, dctx=None ): - super(node_res_dir,self).__init__(path, parent,context) + def __init__(self, path, parent, context, dirr, dctx=None ): + super(node_res_dir,self).__init__(path, parent, context) self.dir_id = dirr.id #todo: more info from dirr self.mimetype = 'application/x-directory' @@ -400,7 +400,7 @@ class node_res_dir(node_class): return res[0] return None - def _child_get(self,cr, name = None, domain=None): + def _child_get(self, cr, name = None, domain=None): """ return virtual children of resource, based on the foreign object. @@ -409,7 +409,6 @@ class node_res_dir(node_class): """ obj = self.context._dirobj.pool.get(self.res_model) if not obj: - print "couldn't find model", self.res_model return [] dirobj = self.context._dirobj uid = self.context.uid @@ -432,12 +431,12 @@ class node_res_dir(node_class): if obj._parent_name in obj.fields_get(cr, uid): where.append((obj._parent_name,'=',object2 and object2.id or False)) - resids = obj.search(cr,uid, where, context=ctx) + resids = obj.search(cr, uid, where, context=ctx) res = [] - for bo in obj.browse(cr,uid,resids,context=ctx): + for bo in obj.browse(cr, uid, resids, context=ctx): if not bo: continue - name = getattr(bo,self.namefield) + name = getattr(bo, self.namefield) if not name: continue # Yes! we can't do better but skip nameless records. @@ -479,7 +478,7 @@ class node_res_obj(node_class): dc2['this'] = res_bo for fld,expr in self.dctx_dict.items(): try: - self.dctx[fld] = safe_eval(expr,dc2) + self.dctx[fld] = safe_eval(expr, dc2) except Exception,e: print "Cannot eval %s for %s" % (expr, fld) print e @@ -490,11 +489,11 @@ class node_res_obj(node_class): def children(self, cr, domain=None): return self._child_get(cr, domain=domain) + self._file_get(cr) - def child(self,cr, name, domain=None): + def child(self, cr, name, domain=None): res = self._child_get(cr, name, domain=domain) if res: return res[0] - res = self._file_get(cr,name) + res = self._file_get(cr, name) if res: return res[0] return None @@ -509,9 +508,9 @@ class node_res_obj(node_class): #if self.domain: # where.extend(self.domain) # print "res_obj file_get clause", where - ids = cntobj.search(cr,uid,where,context=ctx) - for content in cntobj.browse(cr,uid,ids,context=ctx): - res3 = cntobj._file_get(cr,self,nodename,content, context=ctx) + ids = cntobj.search(cr, uid, where, context=ctx) + for content in cntobj.browse(cr, uid, ids, context=ctx): + res3 = cntobj._file_get(cr, self, nodename, content, context=ctx) if res3: res.extend(res3) @@ -524,15 +523,15 @@ class node_res_obj(node_class): ctx = self.context.context.copy() ctx.update(self.dctx) where = [('directory_id','=',self.dir_id) ] - ids = cntobj.search(cr,uid,where,context=ctx) - for content in cntobj.browse(cr,uid,ids,context=ctx): + ids = cntobj.search(cr, uid, where, context=ctx) + for content in cntobj.browse(cr, uid, ids, context=ctx): if content.extension == '.ics': # FIXME: call the content class! res['http://groupdav.org/'] = ('resourcetype',) return res - def get_dav_eprop(self,cr,ns,prop): + def get_dav_eprop(self, cr, ns, prop): if ns != 'http://groupdav.org/' or prop != 'resourcetype': - print "Who asked for %s:%s?" % (ns,prop) + print "Who asked for %s:%s?" % (ns, prop) return None res = {} cntobj = self.context._dirobj.pool.get('document.directory.content') @@ -541,12 +540,12 @@ class node_res_obj(node_class): ctx.update(self.dctx) where = [('directory_id','=',self.dir_id) ] ids = cntobj.search(cr,uid,where,context=ctx) - for content in cntobj.browse(cr,uid,ids,context=ctx): + for content in cntobj.browse(cr, uid, ids, context=ctx): if content.extension == '.ics': # FIXME: call the content class! return ('vevent-collection','http://groupdav.org/') return None - def _child_get(self,cr, name=None, domain=None): + def _child_get(self, cr, name=None, domain=None): dirobj = self.context._dirobj uid = self.context.uid ctx = self.context.context.copy() @@ -563,8 +562,8 @@ class node_res_obj(node_class): where1 = [] if obj._parent_name in obj.fields_get(cr, uid): where1 = where + [(obj._parent_name, '=', self.res_id)] - resids = obj.search(cr,uid, where1, context=ctx) - for bo in obj.browse(cr,uid,resids,context=ctx): + resids = obj.search(cr, uid, where1, context=ctx) + for bo in obj.browse(cr, uid, resids, context=ctx): namefield = directory.resource_field.name or 'name' if not bo: continue @@ -634,7 +633,7 @@ class node_res_obj(node_class): return dirobj.create(cr, uid, val) - def create_child(self,cr,path,data): + def create_child(self, cr, path, data): """ API function to create a child file object and node Return the node_* created """ @@ -652,18 +651,18 @@ class node_res_obj(node_class): # Datas are not set here } - fil_id = fil_obj.create(cr,uid, val, context=ctx) - fil = fil_obj.browse(cr,uid,fil_id,context=ctx) - fnode = node_file(path,self,self.context,fil) - fnode.set_data(cr,data,fil) + fil_id = fil_obj.create(cr, uid, val, context=ctx) + fil = fil_obj.browse(cr, uid, fil_id, context=ctx) + fnode = node_file(path, self, self.context, fil) + fnode.set_data(cr, data, fil) return fnode def _get_ttag(self,cr): - return 'rodir-%d-%d' % (self.dir_id,self.res_id) + return 'rodir-%d-%d' % (self.dir_id, self.res_id) class node_file(node_class): our_type = 'file' - def __init__(self,path, parent, context, fil): + def __init__(self, path, parent, context, fil): super(node_file,self).__init__(path, parent,context) self.file_id = fil.id #todo: more info from ir_attachment @@ -745,7 +744,7 @@ class node_file(node_class): stor = data_obj.browse(cr, self.context.uid, data_id, context=self.context.context).res_id assert stor stobj = self.context._dirobj.pool.get('document.storage') - return stobj.get_data(cr,self.context.uid,stor, self,self.context.context, fil_obj) + return stobj.get_data(cr, self.context.uid,stor, self,self.context.context, fil_obj) def get_data_len(self, cr, fil_obj = None): # TODO: verify with the storage object! @@ -768,14 +767,14 @@ class node_file(node_class): stor = data_obj.browse(cr, self.context.uid, data_id, context=self.context.context).res_id assert stor stobj = self.context._dirobj.pool.get('document.storage') - return stobj.set_data(cr,self.context.uid,stor, self, data, self.context.context, fil_obj) + return stobj.set_data(cr, self.context.uid,stor, self, data, self.context.context, fil_obj) def _get_ttag(self,cr): return 'file-%d' % self.file_id class node_content(node_class): our_type = 'content' - def __init__(self,path, parent, context, cnt, dctx = None, act_id=None): + def __init__(self, path, parent, context, cnt, dctx = None, act_id=None): super(node_content,self).__init__(path, parent,context) self.cnt_id = cnt.id self.create_date = False @@ -799,7 +798,7 @@ class node_content(node_class): res.name = self return res - def fill_fields(self,cr,dctx = None): + def fill_fields(self, cr, dctx = None): """ Try to read the object and fill missing fields, like mimetype, dates etc. This function must be different from the constructor, because @@ -817,7 +816,7 @@ class node_content(node_class): cntobj = self.context._dirobj.pool.get('document.directory.content') ctx = self.context.context.copy() ctx.update(self.dctx) - data = cntobj.process_read(cr,self.context.uid,self,ctx) + data = cntobj.process_read(cr, self.context.uid, self, ctx) if data: self.content_length = len(data) return data @@ -831,7 +830,7 @@ class node_content(node_class): cntobj = self.context._dirobj.pool.get('document.directory.content') ctx = self.context.context.copy() ctx.update(self.dctx) - return cntobj.process_write(cr,self.context.uid,self, data,ctx) + return cntobj.process_write(cr, self.context.uid, self, data, ctx) def _get_ttag(self,cr): return 'cnt-%d%s' % (self.cnt_id,(self.act_id and ('-' + str(self.act_id))) or '') diff --git a/addons/document/test_cindex.py b/addons/document/test_cindex.py index dc5fcf7ebeb..7c0bcb987f3 100644 --- a/addons/document/test_cindex.py +++ b/addons/document/test_cindex.py @@ -27,20 +27,13 @@ for fname in args: fp = open(fname,'rb') content = fp.read() fp.close() - res = cntIndex.doIndex(content,fname,None,None,True) + res = cntIndex.doIndex(content, fname, None, None, True) else: res = cntIndex.doIndex(None, fname, None, fname,True) - if res: - print "Result: ", res[0] - print res[1] - else: - print "No result" except Exception,e: import traceback,sys tb_s = reduce(lambda x, y: x+y, traceback.format_exception( sys.exc_type, sys.exc_value, sys.exc_traceback)) - print "Traceback:",tb_s - print "Exception: ",e #eof |
