--- versionedFile/versionedFile.py 2005/08/15 08:31:52 1.41 +++ versionedFile/versionedFile.py 2005/11/02 12:38:52 1.50 @@ -1,3 +1,4 @@ + from OFS.Folder import Folder from OFS.Image import File from OFS.Image import cookId @@ -7,13 +8,21 @@ from AccessControl import getSecurityMan from Products.PageTemplates.PageTemplate import PageTemplate from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate from AccessControl import ClassSecurityInfo +<<<<<<< versionedFile.py from Products.ImageArchive.ImageArchive import manage_AddImageZogiLib +from Products.ZCatalog.CatalogPathAwareness import CatalogAware +======= +try: + from Products.ImageArchive.ImageArchive import manage_AddImageZogiLib +except: + print "no images" +>>>>>>> 1.49 from threading import Thread import shutil import tempfile import os.path - +import urllib import time try: @@ -112,7 +121,7 @@ class versionedFileFolder(Folder,ECHO_ba security= ClassSecurityInfo() security.declareProtected('AUTHENTICATED_USER','addFileForm') - + filesMetaType=['versionedFile'] if ECHO_basis: optTMP= Folder.manage_options+ECHO_basis.manage_options else: @@ -328,8 +337,9 @@ class versionedFileFolder(Folder,ECHO_ba return cmp(x[1].getLastVersion().lastEditor().lower(),y[1].getLastVersion().lastEditor().lower()) - versionedFiles=self.ZopeFind(self,obj_metatypes=['versionedFile']) - + versionedFiles=self.ZopeFind(self,obj_metatypes=self.filesMetaType) + + if sortField=='title': versionedFiles.sort(sortName) elif sortField=='date': @@ -453,14 +463,19 @@ def manage_addVersionedFileFolder(self, class versionedFileObject(File): """File Object im Folder""" - + security= ClassSecurityInfo() meta_type = "versionedFileObject" manage_editForm =DTMLFile('dtml/fileEdit',globals(), Kind='File',kind='file') manage_editForm._setName('manage_editForm') +<<<<<<< versionedFile.py + security.declarePublic('getVComment') +======= + security= ClassSecurityInfo() +>>>>>>> 1.49 def getVComment(self): """get the comment of this file""" if not hasattr(self,'vComment') or (not self.vComment) or (self.vComment.lstrip()==""): @@ -495,7 +510,16 @@ class versionedFileObject(File): return REQUEST.RESPONSE.redirect(self.REQUEST.SESSION['refer']) return REQUEST.RESPONSE.redirect(self.aq_parent.absolute_url()+"/history") - +<<<<<<< versionedFile.py + security.declarePublic('getVersionComment') + def getVersionComment(self): + """getversioncomment""" + return self.versionComment + + security.declarePublic('getTime') +======= + security.declarePublic('getTime') +>>>>>>> 1.49 def getTime(self): """getTime""" #return self.bobobase_modification_time().ISO() @@ -511,17 +535,25 @@ class versionedFileObject(File): - def download(self): + def download(self,REQUEST=None,RESPONSE=None): """download and lock""" self.REQUEST.RESPONSE.setHeader("Content-Disposition","""attachement; filename=%s"""%self.getId()) - self.REQUEST.RESPONSE.setHeader("Content-Type","application/octet-stream") - + self.REQUEST.RESPONSE.setHeader("Content-Type","application/octet-stream") + #try: + # txt=self.index_html() + #except: + # txt=self.index_html(REQUEST,RESPONSE) + # + #self.REQUEST.RESPONSE.setHeader("Content-Length","str(len(txt)+1000)") + self.content_type="application/octet-stream" - #self.REQUEST.RESPONSE.redirect(self.absolute_url()) - self.REQUEST.RESPONSE.write(self.index_html()) - #self.REQUEST.RESPONSE.write("bl") - self.REQUEST.close() + self.REQUEST.RESPONSE.redirect(self.absolute_url()) + #txt=urllib.urlopen(self.absolute_url()).read() + #self.REQUEST.RESPONSE.write(txt) + + + #self.REQUEST.close() def downloadLocked(self): """download and lock""" @@ -540,12 +572,27 @@ class versionedFileObject(File): """set version""" self.versionNumber=versionNumber +<<<<<<< versionedFile.py + + security.declarePublic('getVersionNumber') +======= + security.declarePublic('getVersionNumber') +>>>>>>> 1.49 def getVersionNumber(self): """get version""" return self.versionNumber + security.declarePublic('getVersionComment') + def getVersionComment(self): + """get version""" + return self.versionComment + - +<<<<<<< versionedFile.py + security.declarePublic('lastEditor') +======= + security.declarePublic('lastEditor') +>>>>>>> 1.49 def lastEditor(self): """last Editor""" if hasattr(self,'author'): @@ -601,9 +648,15 @@ def manage_addVersionedFileObject(self,i -class versionedFile(Folder): +class versionedFile(CatalogAware,Folder): """Versioniertes File""" + default_catalog='fileCatalog' + + def PrincipiaSearchSource(self): + """Return cataloguable key for ourselves.""" + return str(self) + def __init__(self, id, title, lockedBy,author): """init""" self.id=id @@ -695,6 +748,7 @@ class versionedFile(Folder): tmp=0 lastVersion=None + for version in self.ZopeFind(self): if hasattr(version[1],'versionNumber'): @@ -702,6 +756,9 @@ class versionedFile(Folder): if int(version[1].versionNumber) > tmp: tmp=int(version[1].versionNumber,) lastVersion=version[1] + if lastVersion==None: + lastVersion=version[1] + lastVersion.versionNumber=1 return lastVersion def index_html(self): @@ -709,7 +766,8 @@ class versionedFile(Folder): lastVersion=self.getLastVersion() #return "File:"+self.title+" Version:%i"%lastVersion.versionNumber," modified:",lastVersion.bobobase_modification_time()," size:",lastVersion.getSize(),"modified by:",lastVersion.lastEditor() return "File: %s Version:%i modified:%s size:%s modified by:%s"%(self.title,lastVersion.versionNumber,lastVersion.getTime(),lastVersion.getSize(),lastVersion.lastEditor()) - + security= ClassSecurityInfo() + security.declarePublic('getVersion') def getVersion(self): tmp=0 for version in self.ZopeFind(self): @@ -720,7 +778,7 @@ class versionedFile(Folder): tmp=int(version[1].versionNumber,) return tmp+1 - security= ClassSecurityInfo() + security.declareProtected('AUTHENTICATED_USER','unlock') def history(self): @@ -817,15 +875,22 @@ class versionedFile(Folder): """download and lock""" self.REQUEST.RESPONSE.setHeader("Content-Disposition","""attachement; filename=%s"""%self.getLastVersion().getId()) - self.REQUEST.RESPONSE.setHeader("Content-Type","application/octet-stream") + self.REQUEST.RESPONSE.setHeader("Content-Type","application/octet-stream") + #try: + # txt=self.getLastVersion.index_html() + #except: + # txt=self.getLastVersion.index_html(REQUEST,RESPONSE) + + #self.REQUEST.RESPONSE.setHeader("Content-Length","str(len(txt)+1000)") + self.content_type="application/octet-stream" #self.REQUEST.RESPONSE.write("bl") - self.REQUEST.RESPONSE.write(self.getLastVersion().index_html()) - self.REQUEST.close() + #self.REQUEST.RESPONSE.write(txt) + #self.REQUEST.close() #self.getLastVersion().content_type="application/octet-stream" - #self.REQUEST.RESPONSE.redirect(self.REQUEST['URL1']+'/'+self.getId()+'/'+self.getLastVersion().getId()) + self.REQUEST.RESPONSE.redirect(self.REQUEST['URL1']+'/'+self.getId()+'/'+self.getLastVersion().getId()) def downloadLocked(self): """download and lock"""