version 1.47, 2006/10/05 06:38:13
|
version 1.48, 2006/10/05 07:22:58
|
Line 1
|
Line 1
|
"""CDLI extensions of the filearchive""" |
"""CDLI extensions of the filearchive""" |
from Products.versionedFile.versionedFile import * |
|
from Products.versionedFile.extVersionedFile import * |
from Products.versionedFile.extVersionedFile import * |
from Products.ZCatalog.CatalogPathAwareness import CatalogAware |
from Products.ZCatalog.CatalogPathAwareness import CatalogAware |
from tempfile import mkstemp,mkdtemp |
from tempfile import mkstemp,mkdtemp |
Line 142 class uploadATFfinallyThread(Thread):
|
Line 141 class uploadATFfinallyThread(Thread):
|
if len(founds)>0: |
if len(founds)>0: |
SESSION['author']=str(username) |
SESSION['author']=str(username) |
self.result+="<p>Changing : %s"%fn |
self.result+="<p>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 |
#now add the new files |
Line 525 class BasketObject_old(Folder):
|
Line 524 class BasketObject_old(Folder):
|
|
|
ret="" |
ret="" |
lockedObjects={} |
lockedObjects={} |
print "x",self.temp_folder.downloadCounter |
|
if self.temp_folder.downloadCounter > 10: |
if self.temp_folder.downloadCounter > 10: |
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!""" |
|
|
Line 1311 class CDLIFileObject(CatalogAware,extVer
|
Line 1310 class CDLIFileObject(CatalogAware,extVer
|
manage_addCDLIFileObjectForm=DTMLFile('dtml/fileAdd', globals(),Kind='CDLIFileObject',kind='CDLIFileObject', version='1') |
manage_addCDLIFileObjectForm=DTMLFile('dtml/fileAdd', globals(),Kind='CDLIFileObject',kind='CDLIFileObject', version='1') |
|
|
def manage_addCDLIFileObject(self,id,vC='',author='', file='',title='',precondition='', content_type='', |
def manage_addCDLIFileObject(self,id,vC='',author='', file='',title='',precondition='', content_type='', |
REQUEST=None): |
from_tmp=False,REQUEST=None): |
"""Add a new File object. |
"""Add a new File object. |
|
|
Creates a new File object 'id' with the contents of 'file'""" |
Creates a new File object 'id' with the contents of 'file'""" |
Line 1335 def manage_addCDLIFileObject(self,id,vC=
|
Line 1334 def manage_addCDLIFileObject(self,id,vC=
|
|
|
# Now we "upload" the data. By doing this in two steps, we |
# Now we "upload" the data. By doing this in two steps, we |
# can use a database trick to make the upload more efficient. |
# can use a database trick to make the upload more efficient. |
if file: |
|
|
if file and not from_tmp: |
self._getOb(id).manage_upload(file) |
self._getOb(id).manage_upload(file) |
|
elif file and from_tmp: |
|
self._getOb(id).manage_upload_from_tmp(file) |
if content_type: |
if content_type: |
self._getOb(id).content_type=content_type |
self._getOb(id).content_type=content_type |
|
|
Line 1411 class CDLIFile(extVersionedFile,CatalogA
|
Line 1413 class CDLIFile(extVersionedFile,CatalogA
|
precondition='', |
precondition='', |
content_type='', |
content_type='', |
changeName='no',newName='', |
changeName='no',newName='', |
come_from=None,RESPONSE=None): |
come_from=None, |
|
from_tmp=False,RESPONSE=None): |
"""add""" |
"""add""" |
|
|
try: #TODO: der ganze vC unsinn muss ueberarbeitet werden |
try: #TODO: der ganze vC unsinn muss ueberarbeitet werden |
vC=self.REQUEST['vC'] |
vC=self.REQUEST['vC'] |
except: |
except: |
Line 1445 class CDLIFile(extVersionedFile,CatalogA
|
Line 1449 class CDLIFile(extVersionedFile,CatalogA
|
id=tmp[0]+"_V%i"%self.getVersion() |
id=tmp[0]+"_V%i"%self.getVersion() |
|
|
|
|
manage_addCDLIFileObject(self,id,vC,author,file,id,precondition, content_type) |
manage_addCDLIFileObject(self,id,vC,author,file,id,precondition, content_type,from_tmp=from_tmp) |
objs=self.ZopeFind(self,obj_ids=[id])[0][1].setVersionNumber(int(self.getVersion())) |
#objs=self.ZopeFind(self,obj_ids=[id])[0][1].setVersionNumber(int(self.getVersion())) |
|
objs=getattr(self,id).setVersionNumber(int(self.getVersion())) |
try: |
try: |
#FIXME: wozu ist das gut? |
#FIXME: wozu ist das gut? |
self.REQUEST.SESSION['objID_parent']=self.getId() |
self.REQUEST.SESSION['objID_parent']=self.getId() |
Line 1497 def checkFile(filename,data,folder):
|
Line 1502 def checkFile(filename,data,folder):
|
"""check the files""" |
"""check the files""" |
# first check the file name |
# first check the file name |
fn=filename.split(".") # no extension |
fn=filename.split(".") # no extension |
print "_____",fn |
|
if not fn[0][0]=="P": |
if not fn[0][0]=="P": |
return False,"P missing in the filename" |
return False,"P missing in the filename" |
elif len(fn[0])!=7: |
elif len(fn[0])!=7: |
Line 1509 def checkFile(filename,data,folder):
|
Line 1514 def checkFile(filename,data,folder):
|
ret= out.close() |
ret= out.close() |
|
|
if value: |
if value: |
print "ERRR" |
|
return False,"atf checker error: %s"%value |
return False,"atf checker error: %s"%value |
else: |
else: |
return True,"" |
return True,"" |
Line 1693 class CDLIFileFolder(extVersionedFileFol
|
Line 1698 class CDLIFileFolder(extVersionedFileFol
|
|
|
catalog=getattr(self,self.default_catalog) |
catalog=getattr(self,self.default_catalog) |
#tf,tfilename=mkstemp() |
#tf,tfilename=mkstemp() |
print self.temp_folder.downloadCounter |
|
if self.temp_folder.downloadCounter > 5: |
if self.temp_folder.downloadCounter > 5: |
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!""" |
|
|
Line 2053 class CDLIRoot(Folder):
|
Line 2058 class CDLIRoot(Folder):
|
else: |
else: |
fobj2=obj2[0][1] |
fobj2=obj2[0][1] |
|
|
file2=file(os.path.join(folderName,f)) |
file2=os.path.join(folderName,f) |
id=f |
id=f |
manage_addCDLIFile(fobj2,f,'','') |
manage_addCDLIFile(fobj2,f,'','') |
id=f |
id=f |
ob=fobj2._getOb(f) |
ob=fobj2._getOb(f) |
ob.title=id |
ob.title=id |
|
|
manage_addCDLIFileObject(ob,id,comment,author,file2,content_type='') |
manage_addCDLIFileObject(ob,id,comment,author,file2,content_type='',from_tmp=True) |
self.CDLICatalog.catalog_object(ob) |
self.CDLICatalog.catalog_object(ob) |
#self.CDLICatalog.manage_catalogFoundItems(obj_ids=[id],search_sub=1) |
#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]) |
#self.CDLICatalog.manage_catalogObject(self.REQUEST, self.REQUEST.RESPONSE, 'CDLICatalog', urlparse.urlparse(ob.absolute_url())[1]) |