--- cdli/cdli_files.py 2008/10/29 12:10:05 1.102 +++ cdli/cdli_files.py 2008/11/05 19:53:32 1.103 @@ -19,7 +19,6 @@ from ZPublisher.HTTPRequest import HTTPR from ZPublisher.HTTPResponse import HTTPResponse from ZPublisher.BaseRequest import RequestContainer import threading -from BTrees.OOBTree import OOBTree, OOTreeSet import logging import transaction import copy @@ -31,7 +30,8 @@ from sets import Set import md5 from DownloadBasket import DownloadBasketFinallyThread from types import * - +import pickle + def makelist(mySet): x = list(mySet) x.sort() @@ -641,6 +641,10 @@ class CDLIBasketContainer(OrderedFolder) security=ClassSecurityInfo() meta_type="CDLIBasketContainer" + def getResultHash(self): + """get the result hash for debug purposes""" + return self.resultHash.keys() + def getPNumbersOfBasket(self,basketName): """get all pnumbers of a basket as a list, returns an empty list if basket not found @param basketName: name of the basket @@ -1446,9 +1450,16 @@ class CDLIBasketVersion(Implicit,Persist return """I am sorry, currently the server has to many requests for downloads, please come back later!""" - if (check=="yes") and self.containsNonActualFiles(): - pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','downloadObjectAsOneFile_check.zpt')).__of__(self) - + #if (check=="yes") and self.containsNonActualFiles(): + # pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','downloadObjectAsOneFile_check.zpt')).__of__(self) + # + # return pt(lock=lock) + + # neue Version aus Performancegruenden, es wird nicht mehr getestet, ob es nicht aktuelle Objekte gibt + # sondern lediglich gefragt. + if (check=="yes"): + pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','downloadObjectAsOneFile_ask.zpt')).__of__(self) + return pt(lock=lock) else: @@ -1578,8 +1589,35 @@ class CDLIBasketVersion(Implicit,Persist self._v_downloadBasket[threadName]=thread #files = self._v_downloadBasket[threadName].result - files=self.basketContainer.resultHash[threadName] - lockedFiles=self.basketContainer.resultLockedHash[threadName] + # lade die files und die locked files, bei grossen Baskets muss u.U. gewartet werden + # bis das Commit aus dem Thread alles geschrieben hat, in dem Falle existiert resultHash[threadName] + # noch nicht. + o1 = file("/tmp/"+threadName,'r') + files=pickle.load(o1) + os.remove("/tmp/"+threadName) + o2 = file("/tmp/"+threadName+'_lockedFiles','r') + + lockedFiles=pickle.load(o2) + os.remove("/tmp/"+threadName+'_lockedFiles') +# try: +# files=self.basketContainer.resultHash[threadName] +# except: +# i=0 +# while (not self.basketContainer.resultHash.has_key(threadName)) and (i<100): +# logging.debug(" downloadFinally: I am waiting for thread %s to write the resultHashfile: %s"%(threadName,i)) +# time.sleep(5) +# i+=1 +# files=self.basketContainer.resultHash[threadName] +# +# try: +# lockedFiles=self.basketContainer.resultLockedHash[threadName] +# except: +# i=0 +# while (not self.basketContainer.resultLockedHash.has_key(threadName)) and (i<100): +# logging.debug(" downloadFinally: I am waiting for thread %s to write the LockedHashfile: %s"%(threadName,i)) +# time.sleep(5) +# i+=1 +# lockedFiles=self.basketContainer.resultLockedHash[threadName] # fh=file("/var/tmp/test") #ret =fh.read()