version 1.7, 2007/09/10 16:34:16
|
version 1.9, 2007/09/10 19:27:55
|
Line 29 import os.path
|
Line 29 import os.path
|
import urllib |
import urllib |
import time |
import time |
import logging |
import logging |
|
import types |
|
|
try: |
try: |
from Products.ECHO_content.ECHO_collection import ECHO_basis |
from Products.ECHO_content.ECHO_collection import ECHO_basis |
Line 186 class extVersionedFileFolder(Folder,ECHO
|
Line 187 class extVersionedFileFolder(Folder,ECHO
|
return pt() |
return pt() |
|
|
def importFolder(self,path,comment="",author=None,lockedBy=None,RESPONSE=None): |
def importFolder(self,path,comment="",author=None,lockedBy=None,RESPONSE=None): |
"""importiere inhalt eines folders""" |
"""import contents of a folder on the server""" |
|
|
for fileName in os.listdir(path): |
for fileName in os.listdir(path): |
if os.path.isfile(os.path.join(path,fileName)): |
fn = os.path.join(path,fileName) |
manage_addextVersionedFile(self,fileName,'','') |
if os.path.isfile(fn): |
id=fileName |
f = file(fn) |
ob=self._getOb(fileName) |
self.addFile(vC=comment, file=f, author=author) |
ob.title=id |
|
file2=file(os.path.join(path,fileName)) |
|
|
|
obj=ob.manage_addextVersionedFileObject(id,comment,author,file2,content_type='') |
|
|
|
if RESPONSE: |
if RESPONSE: |
RESPONSE.redirect(self.REQUEST['URL1']) |
RESPONSE.redirect(self.REQUEST['URL1']) |
Line 216 class extVersionedFileFolder(Folder,ECHO
|
Line 212 class extVersionedFileFolder(Folder,ECHO
|
downloadZip=generateDownloadZip(self,self.absolute_url()) |
downloadZip=generateDownloadZip(self,self.absolute_url()) |
downloadZip() |
downloadZip() |
return downloadZip.getResult() |
return downloadZip.getResult() |
|
|
## if not threadName or threadName=="": |
## if not threadName or threadName=="": |
## threadStart=generateDownloadZip(self,self.absolute_url()) |
## threadStart=generateDownloadZip(self,self.absolute_url()) |
## thread=Thread(target=threadStart) |
## thread=Thread(target=threadStart) |
Line 435 class extVersionedFileFolder(Folder,ECHO
|
Line 432 class extVersionedFileFolder(Folder,ECHO
|
return out() |
return out() |
|
|
|
|
def addFile(self,vC,file,author,newName='',content_type='',RESPONSE=None): |
def addFile(self,vC,file,author='',newName='',content_type='',RESPONSE=None): |
""" add a new file""" |
""" add a new file""" |
|
# is file is a real file or a zope download object? |
|
isRealFile = type(file) is types.FileType |
|
|
if newName=='': |
if newName=='': |
|
logging.debug("fileobject: %s real:%s"%(repr(file),repr(isRealFile))) |
|
if isRealFile: |
|
filename = file.name |
|
else: |
filename=file.filename |
filename=file.filename |
|
|
id=filename[max(filename.rfind('/'), |
id=filename[max(filename.rfind('/'), |
filename.rfind('\\'), |
filename.rfind('\\'), |
filename.rfind(':'), |
filename.rfind(':'), |
Line 447 class extVersionedFileFolder(Folder,ECHO
|
Line 452 class extVersionedFileFolder(Folder,ECHO
|
else: |
else: |
id=newName |
id=newName |
|
|
|
if not vC: |
vC=self.REQUEST.form['vC'] |
vC=self.REQUEST.form['vC'] |
manage_addextVersionedFile(self,id,'','') |
|
#if (getattr(self,'commentNonEmpty',0)==1) and vC.strip()=="": |
|
|
|
ob=self._getOb(id) |
# get new extVersionedFile |
ob.title=id |
vf = self._newVersionedFile(id,title=id) |
file2=file |
#if (getattr(self,'commentNonEmpty',0)==1) and vC.strip()=="": |
|
# add file to this folder |
|
self._setObject(id,vf) |
|
# add its content |
|
logging.info("ADD: %s"%repr(vf)) |
|
obj=vf.addContentObject(id,vC,author=author,file=file,content_type=content_type,from_tmp=isRealFile) |
|
|
logging.info("ADD: %s"%repr(ob)) |
self.REQUEST.SESSION['objID']=vf.getId() |
obj=ob.manage_addVersionedFileObject(id,vC,author,file2,content_type=content_type) |
|
self.REQUEST.SESSION['objID']=ob.getId() |
|
self.REQUEST.SESSION['objID_parent']=None |
self.REQUEST.SESSION['objID_parent']=None |
|
|
if obj.getSize()==0: |
if obj.getSize()==0: |
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','errorUploadFile')).__of__(self) |
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','errorUploadFile')).__of__(self) |
return pt() |
return pt() |
|
|
|
if RESPONSE is not None: |
RESPONSE.redirect(self.REQUEST['URL1']) |
RESPONSE.redirect(self.REQUEST['URL1']) |
|
|
|
|
|
def _newVersionedFile(self, id, title='', lockedBy=None, author=None): |
|
"""factory for versioned files. to be overridden in derived classes.""" |
|
return extVersionedFile(id, title, lockedBy=lockedBy, author=author) |
|
|
|
|
def deleteEmptyObject(self,submit,RESPONSE=None): |
def deleteEmptyObject(self,submit,RESPONSE=None): |
"""deleteemptyobject""" |
"""deleteemptyobject""" |
if submit=="delete it": |
if submit=="delete it": |
Line 486 class extVersionedFileFolder(Folder,ECHO
|
Line 499 class extVersionedFileFolder(Folder,ECHO
|
for (id,vf) in self.getVersionedFiles(): |
for (id,vf) in self.getVersionedFiles(): |
vf.fixVersionNumbers() |
vf.fixVersionNumbers() |
|
|
|
|
manage_addextVersionedFileFolderForm=DTMLFile('dtml/extfolderAdd', globals()) |
manage_addextVersionedFileFolderForm=DTMLFile('dtml/extfolderAdd', globals()) |
|
|
|
|
Line 998 class extVersionedFile(CatalogAware,Fold
|
Line 1012 class extVersionedFile(CatalogAware,Fold
|
self.lastVersionNumber = versNum |
self.lastVersionNumber = versNum |
self.lastVersionId = id |
self.lastVersionId = id |
|
|
logging.debug("addcontentobject: lastversion=%s"%self.getData()) |
#logging.debug("addcontentobject: 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("addcontentobject: fob_data=%s"%fob.getData()) |
#logging.debug("addcontentobject: fob_data=%s"%fob.getData()) |
|
|
return fob |
return fob |
|
|