version 1.80.2.11, 2007/12/13 19:20:45
|
version 1.80.2.12, 2008/01/02 16:58:12
|
Line 321 class uploadATFfinallyThread(Thread):
|
Line 321 class uploadATFfinallyThread(Thread):
|
self.result+="<h2>Start processing</h2>" |
self.result+="<h2>Start processing</h2>" |
|
|
#shall I only upload the changed files? |
#shall I only upload the changed files? |
logging.info("uploadATFfinally procedure: %s"%procedure) |
logging.debug("uploadATFfinally procedure: %s"%procedure) |
if procedure=="uploadchanged": |
if procedure=="uploadchanged": |
changed=[x[0] for x in SESSION.get('changed',[])] |
changed=[x[0] for x in SESSION.get('changed',[])] |
uploadFns=changed+SESSION.get('newPs',[]) |
uploadFns=changed+SESSION.get('newPs',[]) |
Line 342 class uploadATFfinallyThread(Thread):
|
Line 342 class uploadATFfinallyThread(Thread):
|
#do first the changed files |
#do first the changed files |
i=0 |
i=0 |
for fn in uploadFns: |
for fn in uploadFns: |
|
logging.debug("uploadATFfinally uploadFn=%s"%fn) |
i+=1 |
i+=1 |
founds=ctx2.CDLICatalog.search({'title':fn}) |
founds=ctx2.CDLICatalog.search({'title':fn}) |
if len(founds)>0: |
if len(founds)>0: |
SESSION['author']=str(username) |
SESSION['author']=str(username) |
self.result="<p>Changing : %s"%fn+self.result |
self.result="<p>Changing : %s"%fn+self.result |
|
logging.debug("uploadatffinallythread changing:%s"%fn+self.result) |
founds[0].getObject().manage_addCDLIFileObject('',comment,SESSION['author'],file=os.path.join(SESSION['tmpdir'],fn),from_tmp=True) |
founds[0].getObject().manage_addCDLIFileObject('',comment,SESSION['author'],file=os.path.join(SESSION['tmpdir'],fn),from_tmp=True) |
if i==200: |
if i%200==0: |
i=0 |
|
transaction.get().commit() |
transaction.get().commit() |
logging.info("changing: do commit") |
logging.debug("uploadatffinallythread changing: do commit") |
|
|
transaction.get().commit() |
transaction.get().commit() |
logging.info("changing: last commit") |
logging.debug("uploadatffinallythread changing: last commit") |
|
|
#now add the new files |
#now add the new files |
newPs=SESSION['newPs'] |
newPs=SESSION['newPs'] |
if len(newPs)>0: |
if len(newPs)>0: |
tmpDir=SESSION['tmpdir'] |
tmpDir=SESSION['tmpdir'] |
logging.info("adding start") |
logging.debug("uploadatffinallythread adding start") |
self.result="<p>Adding files</p>"+self.result |
self.result="<p>Adding files</p>"+self.result |
#TODO: make this configurable, at the moment base folder for the files has to be cdli_main |
#TODO: make this configurable, at the moment base folder for the files has to be cdli_main |
|
|
ctx2.importFiles(comment=comment,author=str(username) ,folderName=tmpDir, files=newPs,ext=self) |
ctx2.importFiles(comment=comment,author=str(username) ,folderName=tmpDir, files=newPs,ext=self) |
logging.info("adding finished") |
logging.debug("uploadatffinallythread adding finished") |
|
|
|
|
#unlock locked files? |
#unlock locked files? |
if unlock: |
if unlock: |
logging.info("unlocking start") |
logging.debug("uploadatffinallythread unlocking start") |
self.result="<p>Unlock files</p>"+self.result |
self.result="<p>Unlock files</p>"+self.result |
unlockFns=[] |
unlockFns=[] |
for x in os.listdir(SESSION['tmpdir']): |
for x in os.listdir(SESSION['tmpdir']): |
if not x in SESSION['errors']: |
if not x in SESSION['errors']: |
unlockFns.append(x) |
unlockFns.append(x) |
logging.info("unlocking have now what to unlock") |
|
|
logging.debug("unlocking have now what to unlock") |
|
|
for fn in unlockFns: |
for fn in unlockFns: |
#logging.info("will unlock: %s"%fn) |
#logging.info("will unlock: %s"%fn) |
Line 385 class uploadATFfinallyThread(Thread):
|
Line 385 class uploadATFfinallyThread(Thread):
|
if len(founds)>0: |
if len(founds)>0: |
#logging.info("unlock: %s"%founds[0].getObject().getId()) |
#logging.info("unlock: %s"%founds[0].getObject().getId()) |
SESSION['author']=str(username) |
SESSION['author']=str(username) |
|
|
founds[0].getObject().lockedBy="" |
founds[0].getObject().lockedBy="" |
logging.info("unlocking done") |
|
|
logging.debug("uploadatffinallythread unlocking done") |
|
|
#if a basketname is given, add files to the basket |
#if a basketname is given, add files to the basket |
if not (basketname ==''): |
if not (basketname ==''): |
logging.info("add to basket %s"%basketname) |
logging.debug("uploadatffinallythread add to basket %s"%basketname) |
self.result="<p>Add to basket</p>"+self.result |
self.result="<p>Add to basket</p>"+self.result |
basketId=ctx2.basketContainer.getBasketIdfromName(basketname) |
basketId=ctx2.basketContainer.getBasketIdfromName(basketname) |
|
|
if not basketId: # create new basket |
if not basketId: # create new basket |
logging.info("create basket %s"%basketname) |
logging.debug("uploadatffinallythread create basket %s"%basketname) |
self.result="<p>Create a new basket</p>"+self.result |
self.result="<p>Create a new basket</p>"+self.result |
ob=ctx2.basketContainer.addBasket(basketname) |
ob=ctx2.basketContainer.addBasket(basketname) |
basketId=ob.getId() |
basketId=ob.getId() |
Line 404 class uploadATFfinallyThread(Thread):
|
Line 404 class uploadATFfinallyThread(Thread):
|
ids=os.listdir(SESSION['tmpdir']) |
ids=os.listdir(SESSION['tmpdir']) |
basket.addObjects(ids,deleteOld=True,username=str(username)) |
basket.addObjects(ids,deleteOld=True,username=str(username)) |
|
|
|
logging.debug("uploadatffinallythread uploadfinally done") |
|
|
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect(self.aq_parent.absolute_url()) |
RESPONSE.redirect(self.aq_parent.absolute_url()) |
|
|
|
|
logging.info("uploadfinally done") |
|
return True |
return True |
|
|
class tmpStore(SimpleItem): |
class tmpStore(SimpleItem): |
Line 1614 def manage_addCDLIFileObject(self,id,vC=
|
Line 1614 def manage_addCDLIFileObject(self,id,vC=
|
if content_type: |
if content_type: |
fob.content_type=content_type |
fob.content_type=content_type |
|
|
logging.debug("manage_add: lastversion=%s"%self.getData()) |
#logging.debug("manage_add: lastversion=%s"%self.getData()) |
logging.debug("reindex1: %s in %s"%(repr(self),repr(self.default_catalog))) |
logging.debug("reindex1: %s in %s"%(repr(self),repr(self.default_catalog))) |
self.reindex_object() |
self.reindex_object() |
logging.debug("manage_add: fob_data=%s"%fob.getData()) |
#logging.debug("manage_add: fob_data=%s"%fob.getData()) |
logging.debug("reindex2: %s in %s"%(repr(fob), repr(fob.default_catalog))) |
logging.debug("reindex2: %s in %s"%(repr(fob), repr(fob.default_catalog))) |
fob.index_object() |
fob.index_object() |
|
|
Line 1696 class CDLIFile(extVersionedFile,CatalogA
|
Line 1696 class CDLIFile(extVersionedFile,CatalogA
|
|
|
def _newContentObject(self, id, title='', versionNumber=0, versionComment=None, time=None, author=None): |
def _newContentObject(self, id, title='', versionNumber=0, versionComment=None, time=None, author=None): |
"""factory for content objects. to be overridden in derived classes.""" |
"""factory for content objects. to be overridden in derived classes.""" |
|
logging.debug("_newContentObject(CDLI)") |
return CDLIFileObject(id,title,versionNumber=versionNumber,versionComment=versionComment,time=time,author=author) |
return CDLIFileObject(id,title,versionNumber=versionNumber,versionComment=versionComment,time=time,author=author) |
|
|
|
|
Line 1765 def manage_addCDLIFile(self,id,title,loc
|
Line 1766 def manage_addCDLIFile(self,id,title,loc
|
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
|
|
def checkUTF8(data): |
def checkUTF8(data): |
"""check utf 8""" |
"""check utf 8""" |
try: |
try: |
Line 1856 class CDLIFileFolder(extVersionedFileFol
|
Line 1858 class CDLIFileFolder(extVersionedFileFol
|
#downloadCounter=0 # counts how many download for all files currently run, be mehr als 5 wird verweigert. |
#downloadCounter=0 # counts how many download for all files currently run, be mehr als 5 wird verweigert. |
tmpStore2={} |
tmpStore2={} |
|
|
|
def _newVersionedFile(self, id, title='', lockedBy=None, author=None): |
|
"""factory for versioned files. to be overridden in derived classes.""" |
|
logging.debug("_newVersionedFile(CDLI)") |
|
return CDLIFile(id, title, lockedBy=lockedBy, author=author) |
|
|
def setTemp(self,name,value): |
def setTemp(self,name,value): |
"""set tmp""" |
"""set tmp""" |
|
|
Line 2534 class CDLIRoot(Folder):
|
Line 2541 class CDLIRoot(Folder):
|
|
|
def importFiles(self,comment="",author="" ,folderName="/Users/dwinter/atf", files=None,ext=None): |
def importFiles(self,comment="",author="" ,folderName="/Users/dwinter/atf", files=None,ext=None): |
"""import files""" |
"""import files""" |
|
logging.debug("importFiles folderName=%s files=%s ext=%s"%(folderName,files,ext)) |
root=self.cdli_main |
root=self.cdli_main |
count=0 |
count=0 |
if not files: |
if not files: |
Line 2543 class CDLIRoot(Folder):
|
Line 2551 class CDLIRoot(Folder):
|
folder=f[0:3] |
folder=f[0:3] |
f2=f[0:5] |
f2=f[0:5] |
obj=self.ZopeFind(root,obj_ids=[folder]) |
obj=self.ZopeFind(root,obj_ids=[folder]) |
|
logging.debug("importFiles: folder=%s f2=%s obj=%s"%(folder,f2,obj)) |
if ext: |
if ext: |
|
|
ext.result="<p>adding: %s </p>"%f+ext.result |
ext.result="<p>adding: %s </p>"%f+ext.result |
|
|
if not obj: |
if not obj: |
manage_addCDLIFileFolder(root,folder,folder) |
manage_addCDLIFileFolder(root,folder,folder) |
fobj=getattr(root,folder) |
fobj=getattr(root,folder) |
#transaction.get().commit() |
#transaction.get().commit() |
|
|
else: |
else: |
fobj=obj[0][1] |
fobj=obj[0][1] |
|
|
obj2=fobj.ZopeFind(fobj,obj_ids=[f2]) |
obj2=fobj.ZopeFind(fobj,obj_ids=[f2]) |
|
logging.debug("importFiles: fobj=%s obj2=%s"%(fobj,obj2)) |
|
|
if not obj2: |
if not obj2: |
manage_addCDLIFileFolder(fobj,f2,f2) |
manage_addCDLIFileFolder(fobj,f2,f2) |
Line 2564 class CDLIRoot(Folder):
|
Line 2575 class CDLIRoot(Folder):
|
|
|
file2=os.path.join(folderName,f) |
file2=os.path.join(folderName,f) |
id=f |
id=f |
manage_addCDLIFile(fobj2,f,'','') |
logging.debug("importFiles: addCDLIFile fobj2=%s, f=%s file2=%s"%(fobj2,repr(f),repr(file2))) |
id=f |
fobj2.addFile(vC='',file=file(file2),author=author,newName=f) |
ob=fobj2._getOb(f) |
|
ob.title=id |
|
|
|
manage_addCDLIFileObject(ob,id,comment,author,file2,content_type='',from_tmp=True) |
|
self.CDLICatalog.catalog_object(ob) |
|
#self.CDLICatalog.manage_catalogFoundItems(obj_ids=[id],search_sub=1) |
|
#self.CDLICatalog.manage_catalogObject(self.REQUEST, self.REQUEST.RESPONSE, 'CDLICatalog', urlparse.urlparse(ob.absolute_url())[1]) |
|
count+=1 |
count+=1 |
|
|
if count > 1000: |
if count%100==0: |
print "committing" |
logging.debug("importfiles: committing") |
transaction.get().commit() |
transaction.get().commit() |
count=0 |
|
transaction.get().commit() |
transaction.get().commit() |
return "ok" |
return "ok" |
|
|