--- cdli/cdli_files.py 2006/08/24 09:04:51 1.42 +++ cdli/cdli_files.py 2006/11/14 17:02:59 1.51 @@ -1,11 +1,13 @@ """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 import os from types import * import urlparse +import urllib +import cgi from OFS.OrderedFolder import OrderedFolder from OFS.SimpleItem import SimpleItem import time @@ -98,7 +100,8 @@ class uploadATFfinallyThread(Thread): conn.close() #set flag for end of this method self.end=True - return True + print "ended" + return True def __del__(self): """delete""" @@ -126,7 +129,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 @@ -141,7 +144,7 @@ class uploadATFfinallyThread(Thread): if len(founds)>0: SESSION['author']=str(username) self.result+="
Changing : %s"%fn - founds[0].getObject().manage_addCDLIFileObject('',comment,SESSION['author'],file=file(os.path.join(SESSION['tmpdir'],fn))) + founds[0].getObject().manage_addCDLIFileObject('',comment,SESSION['author'],file=os.path.join(SESSION['tmpdir'],fn),from_tmp=True) #now add the new files @@ -239,10 +242,10 @@ class uploadATFThread(Thread): #ctx.cdliRoot.cdli_main.tmpStore2[self.getName()[0:]]=self.returnValue get_transaction().commit() - + while self.continueVar: pass - + conn.close() @@ -268,6 +271,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 @@ -282,7 +287,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 @@ -308,29 +313,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() + 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 - if (not (str(obj.lockedBy))=='') and (not (str(obj.lockedBy)==str(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 - #ready, set the returnValues self.result+="