--- cdli/cdli_files.py 2006/06/14 18:50:09 1.23 +++ cdli/cdli_files.py 2006/06/15 20:08:44 1.24 @@ -214,7 +214,9 @@ class uploadATFThread(Thread): app = root['Application'] ctx = self.getContext(app,serverport=self.serverport) self.uploadATFThread(ctx,self.upload,self.basketId) - ctx.cdliRoot.cdli_main.tmpStore=self.returnValue + + ctx.cdliRoot.cdli_main.tmpStore2[self.getName()[0:]]=self.returnValue + get_transaction().commit() while self.continueVar: @@ -1263,7 +1265,7 @@ class CDLIFileFolder(versionedFileFolder filesMetaType=['CDLI file'] folderMetaType=['CDLI Folder'] default_catalog='CDLICatalog' - tmpStore=None + tmpStore2={} def setTemp(self,name,value): """set tmp""" @@ -1469,19 +1471,24 @@ class CDLIRoot(Folder): meta_type="CDLIRoot" - def refreshTxt(self,txt=""): + def refreshTxt(self,txt="",threadName=None): """txt fuer refresh""" - return """ 2;url=%s?repeat=%s """%(self.absolute_url()+txt,self.threadName) + return """ 2;url=%s?repeat=%s """%(self.absolute_url()+txt,threadName) - def getResult(self): + def getResult(self,threadName=None): """result of thread""" try: - return self._v_uploadATF.getResult() + return self._v_uploadATF[threadName].getResult() except: return "One moment, please" + + def checkThreads(self): + """check threads""" + return threading.enumerate() + def uploadATF(self,repeat=None,upload=None,basketId=0,RESPONSE=None): """standard ausgabe""" #self._v_uploadATF.returnValue=None @@ -1489,33 +1496,40 @@ class CDLIRoot(Folder): threadName=repeat if not threadName or threadName=="": tmpVar=False + thread=uploadATFThread() - self._v_uploadATF=thread + threadName=thread.getName()[0:] + if not hasattr(self,'_v_uploadATF'): + self._v_uploadATF={} + + self._v_uploadATF[threadName]=thread #self._xmltrans.start() #thread=Thread(target=self._v_uploadATF) - self._v_uploadATF.set(upload,basketId,self.REQUEST['AUTHENTICATED_USER'],serverport=self.REQUEST['SERVER_PORT']) + self._v_uploadATF[threadName].set(upload,basketId,self.REQUEST['AUTHENTICATED_USER'],serverport=self.REQUEST['SERVER_PORT']) #thread.start() - self._v_uploadATF.start() + self._v_uploadATF[threadName].start() - self.threadName=self._v_uploadATF.getName()[0:] + self.threadName=self._v_uploadATF[threadName].getName()[0:] wait_template=self.aq_parent.ZopeFind(self.aq_parent,obj_ids=['wait_template']) if wait_template: return wait_template[0][1]() pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','uploadATFWait.zpt')).__of__(self) - return pt(txt='/uploadATF') + return pt(txt='/uploadATF',threadName=threadName) #_v_xmltrans.run() else: #recover thread, if lost if not hasattr(self,'_v_uploadATF'): + self._v_uploadATF={} + if not self._v_uploadATF.get(threadName,None): for thread in threading.enumerate(): if threadName == thread.getName(): - self._v_uploadATF=thread - - if not self._v_uploadATF.returnValue: + self._v_uploadATF[threadName]=thread + + if not self._v_uploadATF[threadName].returnValue: wait_template=self.aq_parent.ZopeFind(self.aq_parent,obj_ids=['wait_template']) @@ -1524,19 +1538,20 @@ class CDLIRoot(Folder): pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','uploadATFWait.zpt')).__of__(self) - return pt(txt='/uploadATF') + return pt(txt='/uploadATF',threadName=threadName) else: # tmp={} -# for key in self._v_uploadATF.returnValue.keys(): -# t=self._v_uploadATF.returnValue[key] +# for key in self._v_uploadATF[threadName].returnValue.keys(): +# t=self._v_uploadATF[threadName].returnValue[key] # if type(t) is ListType: -# tmp[key]=self._v_uploadATF.returnValue[key][0:] +# tmp[key]=self._v_uploadATF[threadName].returnValue[key][0:] # else: -# tmp[key]=self._v_uploadATF.returnValue[key] - tmp=self.cdli_main.tmpStore - - self._v_uploadATF.continueVar=False +# tmp[key]=self._v_uploadATF[threadName].returnValue[key] + + tmp=self.cdli_main.tmpStore2[threadName] + del(self.cdli_main.tmpStore2[threadName]) + self._v_uploadATF[threadName].continueVar=False self.REQUEST.SESSION['changed']=[x[0].getId() for x in tmp['changed']] self.REQUEST.SESSION['errors']=[x.getId() for x in tmp['errors']] self.REQUEST.SESSION['newPs']=tmp['newPs'] @@ -1553,41 +1568,43 @@ class CDLIRoot(Folder): threadName=repeat if not threadName or threadName=="": - - - self._v_uploadATF=uploadATFfinallyThread() + thread=uploadATFfinallyThread() + threadName=thread.getName()[0:] + self._v_uploadATF[threadName]=thread - self._v_uploadATF.set(procedure,comment=comment,basketname=basketname,unlock=unlock,SESSION=self.REQUEST.SESSION,username=self.REQUEST['AUTHENTICATED_USER'],serverport=self.REQUEST['SERVER_PORT']) + self._v_uploadATF[threadName].set(procedure,comment=comment,basketname=basketname,unlock=unlock,SESSION=self.REQUEST.SESSION,username=self.REQUEST['AUTHENTICATED_USER'],serverport=self.REQUEST['SERVER_PORT']) - self._v_uploadATF.start() + self._v_uploadATF[threadName].start() - self.threadName=self._v_uploadATF.getName()[0:] + wait_template=self.aq_parent.ZopeFind(self.aq_parent,obj_ids=['wait_template']) if wait_template: return wait_template[0][1]() pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','uploadATFWait.zpt')).__of__(self) - return pt(txt='/uploadATFfinally') + return pt(txt='/uploadATFfinally',threadName=threadName) #_v_xmltrans.run() else: #recover thread, if lost if not hasattr(self,'_v_uploadATF'): + self._v_uploadATF={} + if not self._v_uploadATF.get(threadName,None): for thread in threading.enumerate(): if threadName == thread.getName(): - self._v_uploadATF=thread + self._v_uploadATF[threadName]=thread - if hasattr(self,'_v_uploadATF') and (self._v_uploadATF is not None) and (not self._v_uploadATF.end) : + if self._v_uploadATF.get(threadName,None) and (self._v_uploadATF[threadName] is not None) and (not self._v_uploadATF[threadName].end) : wait_template=self.aq_parent.ZopeFind(self.aq_parent,obj_ids=['wait_template']) if wait_template: return wait_template[0][1]() pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','uploadATFWait.zpt')).__of__(self) - return pt(txt='/uploadATFfinally') + return pt(txt='/uploadATFfinally',threadName=threadName) else: if RESPONSE is not None: