version 1.8, 2007/09/10 17:40:37
|
version 1.10, 2007/09/14 12:06: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 196 class extVersionedFileFolder(Folder,ECHO
|
Line 197 class extVersionedFileFolder(Folder,ECHO
|
if RESPONSE: |
if RESPONSE: |
RESPONSE.redirect(self.REQUEST['URL1']) |
RESPONSE.redirect(self.REQUEST['URL1']) |
|
|
|
def importVersionedFileFolderForm(self): |
|
"""form fuer versionedFileFolder import""" |
|
pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','importVersionedFileFolderForm.zpt')).__of__(self) |
|
return pt() |
|
|
|
def importVersionedFileFolder(self,path,RESPONSE=None): |
|
"""import contents of a versionedFileFolder on the server""" |
|
vff = getattr(self.aq_parent, path, None) |
|
if vff is None: |
|
return "SORRY, unable to import %s"%path |
|
|
|
tmpPath=tempfile.mktemp() |
|
if not os.path.exists(tempfile.tempdir): |
|
os.mkdir(tempfile.tempdir) |
|
|
|
if not os.path.exists(tmpPath): |
|
os.mkdir(tmpPath) |
|
|
|
for (vfn, vf) in vff.getVersionedFiles(): |
|
if vf.meta_type == 'versionedFile': |
|
title = vf.title |
|
author = vf.author |
|
vc = getattr(vf.comment, "") |
|
# save file to filesystem |
|
savePath=os.path.join(tmpPath,title) |
|
fh=file(savePath,"w") |
|
fh.write(lastV.getData()) |
|
fh.close() |
|
# and read in again |
|
fh = file(savePath) |
|
self.addFile(vC=vc, file=fh, author=author) |
|
|
|
else: |
|
logging.error("importvff: unable to import %s of type %s!"%(vfn,vf.meta_type)) |
|
|
|
shutil.rmtree(tmpPath) |
|
|
|
if RESPONSE: |
|
RESPONSE.redirect(self.REQUEST['URL1']) |
|
|
zipThreads={} |
zipThreads={} |
zipThreads2={} |
zipThreads2={} |
|
|
Line 433 class extVersionedFileFolder(Folder,ECHO
|
Line 474 class extVersionedFileFolder(Folder,ECHO
|
|
|
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 443 class extVersionedFileFolder(Folder,ECHO
|
Line 492 class extVersionedFileFolder(Folder,ECHO
|
else: |
else: |
id=newName |
id=newName |
|
|
|
if not vC: |
vC=self.REQUEST.form['vC'] |
vC=self.REQUEST.form['vC'] |
|
|
# get new extVersionedFile |
# get new extVersionedFile |
Line 450 class extVersionedFileFolder(Folder,ECHO
|
Line 500 class extVersionedFileFolder(Folder,ECHO
|
#if (getattr(self,'commentNonEmpty',0)==1) and vC.strip()=="": |
#if (getattr(self,'commentNonEmpty',0)==1) and vC.strip()=="": |
# add file to this folder |
# add file to this folder |
self._setObject(id,vf) |
self._setObject(id,vf) |
file2=file |
|
# add its content |
# add its content |
logging.info("ADD: %s"%repr(vf)) |
logging.info("ADD: %s"%repr(vf)) |
obj=vf.addContentObject(id,vC,author=author,file=file2,content_type=content_type) |
obj=vf.addContentObject(id,vC,author=author,file=file,content_type=content_type,from_tmp=isRealFile) |
|
|
self.REQUEST.SESSION['objID']=vf.getId() |
self.REQUEST.SESSION['objID']=vf.getId() |
self.REQUEST.SESSION['objID_parent']=None |
self.REQUEST.SESSION['objID_parent']=None |
Line 462 class extVersionedFileFolder(Folder,ECHO
|
Line 511 class extVersionedFileFolder(Folder,ECHO
|
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']) |
|
|
|
|
Line 1002 class extVersionedFile(CatalogAware,Fold
|
Line 1052 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 |
|
|