--- versionedFile/versionedFile.py 2005/10/17 16:06:27 1.44 +++ versionedFile/versionedFile.py 2005/11/02 12:38:52 1.50 @@ -8,10 +8,15 @@ 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 @@ -116,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: @@ -332,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': @@ -457,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()==""): @@ -499,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() @@ -515,18 +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()) - txt=urllib.urlopen(self.absolute_url()).read() - self.REQUEST.RESPONSE.write(txt) - #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""" @@ -545,7 +572,12 @@ 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 @@ -556,7 +588,11 @@ class versionedFileObject(File): return self.versionComment +<<<<<<< versionedFile.py + security.declarePublic('lastEditor') +======= security.declarePublic('lastEditor') +>>>>>>> 1.49 def lastEditor(self): """last Editor""" if hasattr(self,'author'): @@ -612,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 @@ -706,6 +748,7 @@ class versionedFile(Folder): tmp=0 lastVersion=None + for version in self.ZopeFind(self): if hasattr(version[1],'versionNumber'): @@ -713,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): @@ -829,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"""