version 1.10, 2007/09/14 12:06:55
|
version 1.16, 2007/11/23 18:47:39
|
Line 135 class extVersionedFileFolder(Folder,ECHO
|
Line 135 class extVersionedFileFolder(Folder,ECHO
|
{'label':'Generate Index.html','action':'generateIndexHTML'}, |
{'label':'Generate Index.html','action':'generateIndexHTML'}, |
{'label':'Generate Image Index.html','action':'generateIndexHTML_image'}, |
{'label':'Generate Image Index.html','action':'generateIndexHTML_image'}, |
{'label':'Generate history_template.html','action':'generateHistoryHTML'}, |
{'label':'Generate history_template.html','action':'generateHistoryHTML'}, |
{'label':'Import Folder','action':'importFolderForm'}, |
{'label':'Import directory','action':'importFolderForm'}, |
{'label':'Export Folder','action':'exportFolder'}, |
{'label':'Export as file','action':'exportFolder'}, |
|
{'label':'Import versionedFileFolder','action':'importVersionedFileFolderForm'}, |
{'label':'Position of version number','action':'changeHistoryFileNamesForm'}, |
{'label':'Position of version number','action':'changeHistoryFileNamesForm'}, |
) |
) |
|
|
Line 217 class extVersionedFileFolder(Folder,ECHO
|
Line 218 class extVersionedFileFolder(Folder,ECHO
|
|
|
for (vfn, vf) in vff.getVersionedFiles(): |
for (vfn, vf) in vff.getVersionedFiles(): |
if vf.meta_type == 'versionedFile': |
if vf.meta_type == 'versionedFile': |
|
logging.error("importvff: importing %s of type %s!"%(vfn,vf.meta_type)) |
title = vf.title |
title = vf.title |
author = vf.author |
fob = vf.getLastVersion() |
vc = getattr(vf.comment, "") |
author = fob.getLastEditor() |
|
vc = fob.getVersionComment() |
# save file to filesystem |
# save file to filesystem |
savePath=os.path.join(tmpPath,title) |
savePath=os.path.join(tmpPath,title) |
fh=file(savePath,"w") |
fh=file(savePath,"w") |
fh.write(lastV.getData()) |
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() |
fh.close() |
# and read in again |
# and read in again |
fh = file(savePath) |
fh = file(savePath) |
|
logging.error("importvff: comment=%s author=%s!"%(vc,author)) |
self.addFile(vC=vc, file=fh, author=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: |
else: |
logging.error("importvff: unable to import %s of type %s!"%(vfn,vf.meta_type)) |
logging.error("importvff: unable to import %s of type %s!"%(vfn,vf.meta_type)) |
Line 492 class extVersionedFileFolder(Folder,ECHO
|
Line 509 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 |
Line 538 class extVersionedFileFolder(Folder,ECHO
|
Line 555 class extVersionedFileFolder(Folder,ECHO
|
"""fix last version number of all files""" |
"""fix last version number of all files""" |
for (id,vf) in self.getVersionedFiles(): |
for (id,vf) in self.getVersionedFiles(): |
vf.fixVersionNumbers() |
vf.fixVersionNumbers() |
|
# recursively |
|
for (id,vf) in self.objectItems(self.meta_type): |
|
vf.fixVersionNumbers() |
|
|
|
|
manage_addextVersionedFileFolderForm=DTMLFile('dtml/extfolderAdd', globals()) |
manage_addextVersionedFileFolderForm=DTMLFile('dtml/extfolderAdd', globals()) |
Line 753 class extVersionedFile(CatalogAware,Fold
|
Line 773 class extVersionedFile(CatalogAware,Fold
|
meta_type = 'extVersionedFile' |
meta_type = 'extVersionedFile' |
# meta_type of contained objects |
# meta_type of contained objects |
content_meta_type = ['extVersionedFileObject'] |
content_meta_type = ['extVersionedFileObject'] |
|
# default catalog for extVersionedFile objects |
default_catalog = 'fileCatalog' |
default_catalog = 'fileCatalog' |
|
|
|
manage_options = Folder.manage_options+({'label':'Main Config','action':'changeVersionedFileForm'},) |
|
|
|
|
security=ClassSecurityInfo() |
security=ClassSecurityInfo() |
|
|
def __init__(self, id, title, lockedBy,author): |
def __init__(self, id, title, lockedBy,author): |
Line 901 class extVersionedFile(CatalogAware,Fold
|
Line 925 class extVersionedFile(CatalogAware,Fold
|
|
|
def getContentObject(self): |
def getContentObject(self): |
"""returns the last version object""" |
"""returns the last version object""" |
if not self.lastVersionId: |
if not hasattr(self, 'lastVersionId'): |
|
# find last version and save it |
lv = self.findLastVersion() |
lv = self.findLastVersion() |
if lv is None: |
if lv is None: |
return None |
return None |
Line 1103 class extVersionedFile(CatalogAware,Fold
|
Line 1128 class extVersionedFile(CatalogAware,Fold
|
return ob |
return ob |
|
|
|
|
|
changeVersionedFileForm = PageTemplateFile('zpt/changeVersionedFile', globals()) |
|
|
|
def manage_changeVersionedFile(self,title,vC,author,comment): |
|
"""Change VersionedFile metadata""" |
|
self.title = title |
|
self.author = author |
|
cob = self.getContentObject() |
|
if cob: |
|
if vC: |
|
cob.vComment=vC |
|
|
|
if comment=='': |
|
cob.versionComment=None |
|
else: |
|
cob.versionComment=comment |
|
|
|
if RESPONSE: |
|
RESPONSE.redirect('manage_main') |
|
|
|
|
def download(self): |
def download(self): |
"""download and lock""" |
"""download""" |
self.REQUEST.RESPONSE.setHeader("Content-Disposition","""attachement; filename=%s"""%self.getContentObject().getId()) |
self.REQUEST.RESPONSE.setHeader("Content-Disposition","""attachement; filename=%s"""%self.getContentObject().getId()) |
self.REQUEST.RESPONSE.setHeader("Content-Type","application/octet-stream") |
self.REQUEST.RESPONSE.setHeader("Content-Type","application/octet-stream") |
self.content_type="application/octet-stream" |
self.content_type="application/octet-stream" |
self.REQUEST.RESPONSE.redirect(self.REQUEST['URL1']+'/'+self.getId()+'/'+self.getContentObject().getId()) |
self.REQUEST.RESPONSE.redirect(self.REQUEST['URL1']+'/'+self.getId()+'/'+self.getContentObject().getId()) |
|
|
|
|
security.declareProtected('AUTHENTICATED_USER','downloadLocked') |
security.declareProtected('AUTHENTICATED_USER','downloadLocked') |
def downloadLocked(self): |
def downloadLocked(self): |
"""download and lock""" |
"""download and lock""" |