version 1.9, 2007/09/10 19:27:55
|
version 1.11, 2007/09/14 14:58:28
|
Line 197 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': |
|
logging.error("importvff: importing %s of type %s!"%(vfn,vf.meta_type)) |
|
title = vf.title |
|
fob = vf.getLastVersion() |
|
author = fob.getLastEditor() |
|
vc = fob.getVersionComment() |
|
# save file to filesystem |
|
savePath=os.path.join(tmpPath,title) |
|
fh=file(savePath,"w") |
|
data = vf.getLastVersion().data |
|
if isinstance(data, str): |
|
# simple data object |
|
fh.write(data) |
|
else: |
|
# chained data objects |
|
while data is not None: |
|
fh.write(data.data) |
|
data = data.next |
|
fh.close() |
|
# and read in again |
|
fh = file(savePath) |
|
logging.error("importvff: comment=%s author=%s!"%(vc,author)) |
|
self.addFile(vC=vc, file=fh, author=author) |
|
# copy more fields |
|
newfob = getattr(self, vfn).getContentObject() |
|
newfob.vComment = fob.vComment |
|
newfob.time = fob.time |
|
logging.error("importvff: vc=%s time=%s of %s!"%(fob.vComment,fob.time,fob.getId())) |
|
|
|
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 452 class extVersionedFileFolder(Folder,ECHO
|
Line 508 class extVersionedFileFolder(Folder,ECHO
|
else: |
else: |
id=newName |
id=newName |
|
|
if not vC: |
if vC is None: |
vC=self.REQUEST.form['vC'] |
vC=self.REQUEST.form['vC'] |
|
|
# get new extVersionedFile |
# get new extVersionedFile |