--- versionedFile/versionedFile.py 2005/11/28 12:31:28 1.54 +++ versionedFile/versionedFile.py 2006/05/10 16:58:49 1.57 @@ -518,8 +518,13 @@ class versionedFileObject(File): manage_editForm._setName('manage_editForm') - security.declarePublic('getVComment') + security.declarePublic('getTitle') + def getTitle(self): + """get title""" + return self.title + + security.declarePublic('getVComment') def getVComment(self): """get the comment of this file""" if not hasattr(self,'vComment') or (not self.vComment) or (self.vComment.lstrip()==""): @@ -567,10 +572,10 @@ class versionedFileObject(File): #return self.bobobase_modification_time().ISO() if hasattr(self,'time'): return time.strftime("%Y-%m-%d %H:%M:%S",self.time) - elif hasattr(self,'timefixed'): - return self.timefixed + elif hasattr(self,'timefixed'): + return self.timefixed else: - setattr(self,'timefixed',self.bobobase_modification_time().ISO()) + setattr(self,'timefixed',self.bobobase_modification_time().ISO()) return self.bobobase_modification_time().ISO() @@ -597,11 +602,12 @@ class versionedFileObject(File): #self.REQUEST.close() + security.declareProtected('AUTHENTICATED_USER','downloadLocked') def downloadLocked(self): """download and lock""" - if self.REQUEST['AUTHENTICATED_USER']=='Anonymous User': + if repr(self.REQUEST['AUTHENTICATED_USER'])=='Anonymous User': return "please login first" if not self.aq_parent.lockedBy=="": return "cannot be locked because is already locked by %s"%self.lockedBy @@ -633,7 +639,10 @@ class versionedFileObject(File): def lastEditor(self): """last Editor""" if hasattr(self,'author'): - ret=self.author.replace("-","\n") + try: + ret=self.author.replace("-","\n") + except:#old version of versionded file sometimes stored the user object and not only the name the following corrects this + ret=str(self.author).replace("-","\n") ret=ret.replace("\r","\n") return ret @@ -690,6 +699,10 @@ class versionedFile(CatalogAware,Folder) default_catalog='fileCatalog' + def getTitle(self): + """get title""" + return self.title + def PrincipiaSearchSource(self): """Return cataloguable key for ourselves.""" return str(self) @@ -822,7 +835,9 @@ class versionedFile(CatalogAware,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= ClassSecurityInfo() + + security.declarePublic('getVersion') def getVersion(self): tmp=0 @@ -866,7 +881,7 @@ class versionedFile(CatalogAware,Folder) """unlock""" if str(self.lockedBy) in [str(self.REQUEST['AUTHENTICATED_USER'])]: self.lockedBy='' - RESPONSE.redirect(self.REQUEST['URL2']) + RESPONSE.redirect(self.REQUEST['HTTP_REFERER']) else: return "Sorry, not locked by you! (%s,%s)"%(self.lockedBy,self.REQUEST['AUTHENTICATED_USER']) @@ -961,9 +976,11 @@ class versionedFile(CatalogAware,Folder) #self.getLastVersion().content_type="application/octet-stream" self.REQUEST.RESPONSE.redirect(self.REQUEST['URL1']+'/'+self.getId()+'/'+self.getLastVersion().getId()) + security.declareProtected('AUTHENTICATED_USER','downloadLocked') def downloadLocked(self): """download and lock""" - if self.REQUEST['AUTHENTICATED_USER']=='Anonymous User': + + if repr(self.REQUEST['AUTHENTICATED_USER'])=='Anonymous User': return "please login first" if not self.lockedBy=="": return "cannot be locked because is already locked by %s"%self.lockedBy