version 1.102, 2008/10/29 12:10:05
|
version 1.104, 2008/11/06 15:00:44
|
Line 19 from ZPublisher.HTTPRequest import HTTPR
|
Line 19 from ZPublisher.HTTPRequest import HTTPR
|
from ZPublisher.HTTPResponse import HTTPResponse |
from ZPublisher.HTTPResponse import HTTPResponse |
from ZPublisher.BaseRequest import RequestContainer |
from ZPublisher.BaseRequest import RequestContainer |
import threading |
import threading |
from BTrees.OOBTree import OOBTree, OOTreeSet |
|
import logging |
import logging |
import transaction |
import transaction |
import copy |
import copy |
Line 31 from sets import Set
|
Line 30 from sets import Set
|
import md5 |
import md5 |
from DownloadBasket import DownloadBasketFinallyThread |
from DownloadBasket import DownloadBasketFinallyThread |
from types import * |
from types import * |
|
import pickle |
|
import tempfile |
|
|
def makelist(mySet): |
def makelist(mySet): |
x = list(mySet) |
x = list(mySet) |
Line 538 class uploadATFThread(Thread):
|
Line 539 class uploadATFThread(Thread):
|
ctx2=ctx.cdliRoot |
ctx2=ctx.cdliRoot |
|
|
#get temporary file for staging the downloaded and splitted files |
#get temporary file for staging the downloaded and splitted files |
dir=mkdtemp() |
dir=tempfile.mkdtemp() |
|
|
|
|
changed=[] # changed files |
changed=[] # changed files |
Line 641 class CDLIBasketContainer(OrderedFolder)
|
Line 642 class CDLIBasketContainer(OrderedFolder)
|
security=ClassSecurityInfo() |
security=ClassSecurityInfo() |
meta_type="CDLIBasketContainer" |
meta_type="CDLIBasketContainer" |
|
|
|
def getResultHash(self): |
|
"""get the result hash for debug purposes""" |
|
return self.resultHash.keys() |
|
|
def getPNumbersOfBasket(self,basketName): |
def getPNumbersOfBasket(self,basketName): |
"""get all pnumbers of a basket as a list, returns an empty list if basket not found |
"""get all pnumbers of a basket as a list, returns an empty list if basket not found |
@param basketName: name of the basket |
@param basketName: name of the basket |
Line 1446 class CDLIBasketVersion(Implicit,Persist
|
Line 1451 class CDLIBasketVersion(Implicit,Persist
|
return """I am sorry, currently the server has to many requests for downloads, please come back later!""" |
return """I am sorry, currently the server has to many requests for downloads, please come back later!""" |
|
|
|
|
if (check=="yes") and self.containsNonActualFiles(): |
#if (check=="yes") and self.containsNonActualFiles(): |
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','downloadObjectAsOneFile_check.zpt')).__of__(self) |
# 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) |
return pt(lock=lock) |
|
|
Line 1578 class CDLIBasketVersion(Implicit,Persist
|
Line 1590 class CDLIBasketVersion(Implicit,Persist
|
self._v_downloadBasket[threadName]=thread |
self._v_downloadBasket[threadName]=thread |
|
|
#files = self._v_downloadBasket[threadName].result |
#files = self._v_downloadBasket[threadName].result |
files=self.basketContainer.resultHash[threadName] |
# lade die files und die locked files, bei grossen Baskets muss u.U. gewartet werden |
lockedFiles=self.basketContainer.resultLockedHash[threadName] |
# 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") |
# fh=file("/var/tmp/test") |
#ret =fh.read() |
#ret =fh.read() |
Line 1616 class CDLIBasketVersion(Implicit,Persist
|
Line 1655 class CDLIBasketVersion(Implicit,Persist
|
|
|
self.REQUEST.RESPONSE.write("# locked files end\n") |
self.REQUEST.RESPONSE.write("# locked files end\n") |
|
|
del self.basketContainer.resultHash[threadName] |
#del self.basketContainer.resultHash[threadName] |
del self.basketContainer.resultLockedHash[threadName] |
#del self.basketContainer.resultLockedHash[threadName] |
|
|
def numberOfItems(self): |
def numberOfItems(self): |
"""return anzahl der elemente im basket""" |
"""return anzahl der elemente im basket""" |
Line 2945 class CDLIRoot(Folder):
|
Line 2984 class CDLIRoot(Folder):
|
logging.debug("dir:"+repr(stObj.returnValue['changed'])) |
logging.debug("dir:"+repr(stObj.returnValue['changed'])) |
for x in stObj.returnValue['changed']: |
for x in stObj.returnValue['changed']: |
ob=self.CDLICatalog.search({'title':x[0]}) |
ob=self.CDLICatalog.search({'title':x[0]}) |
|
try: |
self.cdliRoot.updateOrAddToFileBTree(ob[0].getObject()) |
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])) |
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect(self.absolute_url()) |
RESPONSE.redirect(self.absolute_url()) |
|
|