--- cdli/cdli_files.py 2006/06/15 22:02:40 1.25 +++ cdli/cdli_files.py 2006/10/05 06:38:13 1.47 @@ -1,5 +1,6 @@ """CDLI extensions of the filearchive""" from Products.versionedFile.versionedFile import * +from Products.versionedFile.extVersionedFile import * from Products.ZCatalog.CatalogPathAwareness import CatalogAware from tempfile import mkstemp,mkdtemp import os.path @@ -13,14 +14,35 @@ from OFS.Folder import manage_addFolder import re from AccessControl import ClassSecurityInfo from Acquisition import Implicit +from Globals import Persistent from threading import Thread from ZPublisher.HTTPRequest import HTTPRequest from ZPublisher.HTTPResponse import HTTPResponse from ZPublisher.BaseRequest import RequestContainer import threading + +class BasketContent(SimpleItem): + """classe fuer den Inhalt eines Baskets""" + + def __init__(self,content=[]): + """content""" + self.contentList=content[0:] + + def getContent(self): + """get content""" - + return self.contentList + + def setContent(self,content): + self.contentList=content[0:] + + def numberOfItems(self): + """number""" + + return len(self.getContent()) + + class uploadATFfinallyThread(Thread): """class for adding uploaded filed (temporarily stored in the staging area at /tmp""" @@ -58,7 +80,7 @@ class uploadATFfinallyThread(Thread): req = HTTPRequest(None, env, resp) return app.__of__(RequestContainer(REQUEST = req)) - + def run(self): """run""" @@ -105,7 +127,7 @@ class uploadATFfinallyThread(Thread): elif procedure=="uploadAll": uploadFns=[] for x in os.listdir(SESSION['tmpdir']): - if not x in SESSION['errors']: + if not x in SESSION['lockerrors']: uploadFns.append(x) #or maybe nothing @@ -215,7 +237,7 @@ class uploadATFThread(Thread): ctx = self.getContext(app,serverport=self.serverport) self.uploadATFThread(ctx,self.upload,self.basketId) - ctx.cdliRoot.cdli_main.tmpStore2[self.getName()[0:]]=self.returnValue + #ctx.cdliRoot.cdli_main.tmpStore2[self.getName()[0:]]=self.returnValue get_transaction().commit() @@ -247,6 +269,8 @@ class uploadATFThread(Thread): changed=[] # changed files errors=[] # files with errors + lockerrors=[] # files with errors + newPs=[] # new p filed psNotInCatalog=[] # files not in the catalog @@ -261,7 +285,7 @@ class uploadATFThread(Thread): if basketObj: basketId=basketObj.getId() - #if there is no active baske and no basketid given, id is empty, else get besketname and length + #if there is no active basket and no basketid given, id is empty, else get besketname and length if basketId == '0': basketNameFromId="" basketLen=0 @@ -287,29 +311,37 @@ class uploadATFThread(Thread): founds=ctx2.CDLICatalog.search({'title':fn}) #if not than add filename to the list of newfiles - if len(founds)==0: - newPs.append(fn) - #if p file alread at the server - for found in founds: - #analyse the differences to the actual file - obj=found.getObject() - - if (not obj.lockedBy=='') and (not obj.lockedBy==self.username): - errors.append(obj) - else: - data=file(os.path.join(dir,fn)).read() - diffs=obj.diff(data) - if diffs[0]>0: - changed.append((obj,diffs)) - #hochladen - + data=file(os.path.join(dir,fn)).read() + #status,msg=checkFile(fn,data,dir) + status=True + msg="" + if not status: # error + errors.append((fn,msg)) + else: + if len(founds)==0: + newPs.append(fn) + + #if p file alread at the server + for found in founds: + #analyse the differences to the actual file + obj=found.getObject() + + if (not (str(obj.lockedBy))=='') and (not (str(obj.lockedBy)==str(self.username))): + lockerrors.append(fn) + else: + + diffs=obj.diff(data) + if diffs[0]>0: + changed.append((obj,diffs)) #hochladen + #ready, set the returnValues self.result+="