--- cdli/cdli_files.py 2009/06/24 11:13:47 1.112 +++ cdli/cdli_files.py 2009/09/01 08:36:04 1.114 @@ -801,13 +801,34 @@ class CDLIRoot(Folder): if isinstance(fileId,CDLIFileObject): # support for old baskets return fileId x=self.v_files.get(fileId) - + logging.debug("obj: "+repr(x)) + if x==None: + folder=fileId[0:3] + f2=fileId[0:5] + fObj = getattr(self.cdliRoot.cdli_main,folder); + f2Obj = getattr(fObj,f2) + + o = getattr(f2Obj,fileId) + logging.debug(o); + self.updateOrAddToFileBTree(o) + return o return x def getFileObjectLastVersion(self,fileId): """get an object""" x=self.v_files_lastVersion.get(fileId) - #logging.debug("lastVersion: "+repr(x)) + logging.debug("lastVersion: "+repr(x)) + if x==None: + folder=fileId[0:3] + f2=fileId[0:5] + fObj = getattr(self.cdliRoot.cdli_main,folder); + f2Obj = getattr(fObj,f2) + + o =getattr(f2Obj,fileId) + logging.debug(o); + return o.getLastVersion() + + return x def showFileIds(self): @@ -836,8 +857,17 @@ class CDLIRoot(Folder): self.v_files_lastVersion.update({obj.getId():obj.getLastVersion()}) self.v_file_ids.add(obj.getId()) - logging.debug("update:"+obj.getId()+"XXX"+repr(obj)) + #change everthing around to make it persistent... + tmp = self.v_files + self.v_files=tmp + tmp2=self.v_file_ids + self.v_file_ids=tmp2 + + self.CDLICache.cleanCache() #be sure that the cache is clean + logging.debug("update:"+obj.getId()+"XXX"+repr(obj)) + + def deleteFromBTree(self,objId): """delete an obj""" self.v_files.pop(objId) @@ -1349,7 +1379,11 @@ class CDLIRoot(Folder): try: self.cdliRoot.updateOrAddToFileBTree(ob[0].getObject()) except: + logging.error("uploadATFfinally - cannot update Object %s Error: %s %s"%(ob[1],sys.exc_info()[0],sys.exc_info()[1])) + for x in stObj.returnValue['newPs']: + obj=self.getFileObject(x) #updates the object in the cache + logging.debug("Got:"+repr(obj)) if RESPONSE is not None: RESPONSE.redirect(self.absolute_url()) @@ -1396,17 +1430,21 @@ class CDLIRoot(Folder): id=f logging.debug("importFiles: addCDLIFile fobj2=%s, f=%s file2=%s"%(fobj2,repr(f),repr(file2))) fobj2.addFile(vC='',file=file(file2),author=author,newName=f) + logging.debug("importfiles: fobj2.add") count+=1 #now add the file to the storage ob = getattr(fobj2,f) - self.cdliRoot.updateOrAddToFileBTree(ob) - + logging.debug("importfiles: btree_start") + #self.cdliRoot.updateOrAddToFileBTree(ob) + logging.debug("importfiles: btree_end") if count%100==0: logging.debug("importfiles: committing") transaction.get().commit() + logging.debug("importfiles: committing") transaction.get().commit() + logging.debug("importfiles: committing done") return "ok"