~jgrandguillaume-c2c/openobject-addons/multi-company-cost-price

« back to all changes in this revision

Viewing changes to document/nodes.py

  • Committer: Joël Grand-Guillaume
  • Date: 2010-04-08 09:00:10 UTC
  • mfrom: (2533.3.664)
  • Revision ID: joel.grandguillaume@camptocamp.com-20100408090010-c0pqjan341s18bxs
[MRG] Merge from last trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
        context """
50
50
    cached_roots = {}
51
51
 
52
 
    def __init__(self, cr, uid, context=None):
53
 
        # we don't cache the cr!
 
52
    def __init__(self, cr, uid, context=None):        
54
53
        self.dbname = cr.dbname
55
54
        self.uid = uid
56
55
        self.context = context
57
56
        self._dirobj = pooler.get_pool(cr.dbname).get('document.directory')
58
57
        assert self._dirobj
59
 
        self.rootdir = self._dirobj._get_root_directory(cr,uid,context)
 
58
        self.rootdir = False #self._dirobj._get_root_directory(cr,uid,context)
60
59
 
61
60
    def get_uri(self, cr,  uri):
62
61
        """ Although this fn passes back to doc.dir, it is needed since
63
 
        it is a potential caching point """        
 
62
        it is a potential caching point """            
64
63
        (ndir, duri) =  self._dirobj._locate_child(cr,self.uid, self.rootdir,uri, None, self)          
65
64
        while duri:                    
66
65
            ndir = ndir.child(cr, duri[0])            
168
167
    our_type = 'collection'
169
168
    def __init__(self,path, parent, context, dirr, dctx=None):
170
169
        super(node_dir,self).__init__(path, parent,context)
171
 
        self.dir_id = dirr.id
 
170
        self.dir_id = dirr and dirr.id or False
172
171
        #todo: more info from dirr
173
172
        self.mimetype = 'application/x-directory'
174
173
            # 'httpd/unix-directory'
175
 
        self.create_date = dirr.create_date        
176
 
        self.domain = dirr.domain
177
 
        self.res_model = dirr.ressource_type_id and dirr.ressource_type_id.model or False
 
174
        self.create_date = dirr and dirr.create_date or False
 
175
        self.domain = dirr and dirr.domain or []
 
176
        self.res_model = dirr and dirr.ressource_type_id and dirr.ressource_type_id.model or False
178
177
        # TODO: the write date should be MAX(file.write)..
179
 
        self.write_date = dirr.write_date or dirr.create_date
 
178
        self.write_date = dirr and (dirr.write_date or dirr.create_date) or False
180
179
        self.content_length = 0
181
180
        if dctx:
182
181
            self.dctx.update(dctx)
183
182
        dc2 = self.context.context
184
183
        dc2.update(self.dctx)
185
184
        dc2['dir_id'] = self.dir_id
186
 
        self.displayname = dirr.name
187
 
        if dirr.dctx_ids:
 
185
        self.displayname = dirr and dirr.name or False
 
186
        if dirr and dirr.dctx_ids:
188
187
            for dfld in dirr.dctx_ids:
189
188
                try:
190
189
                    self.dctx['dctx_' + dfld.field] = safe_eval(dfld.expr,dc2)