--- versionedFile/versionedFile.py 2004/07/08 15:55:27 1.7 +++ versionedFile/versionedFile.py 2004/07/08 18:56:41 1.11 @@ -99,9 +99,12 @@ class versionedFileFolder(Folder): return out() - def addFile(self,vC,file,author,content_type='',RESPONSE=None): + def addFile(self,vC,file,author,newName='',content_type='',RESPONSE=None): """ add a new file""" - id=file.filename + if newName=='': + id=file.filename + else: + id=newName vC=self.REQUEST.form['vC'] manage_addVersionedFile(self,id,'','') @@ -160,7 +163,7 @@ class versionedFileObject(File): """download and lock""" - self.content_type="octet/stream" + self.content_type="application/octet-stream" self.REQUEST.RESPONSE.redirect(self.absolute_url()) def downloadLocked(self): @@ -173,7 +176,7 @@ class versionedFileObject(File): return "cannot be locked because is already locked by %s"%self.lockedBy self.aq_parent.lockedBy=self.REQUEST['AUTHENTICATED_USER'] - self.content_type="octet/stream" + self.content_type="application/octet-stream" self.REQUEST.RESPONSE.redirect(self.absolute_url()) def setVersionNumber(self,versionNumber): @@ -298,7 +301,7 @@ class versionedFile(Folder): ret.sort(sortv) return ret - + security.declareProtected('AUTHENTICATED_USER','unlock') def unlock(self,RESPONSE): """unlock""" if str(self.lockedBy) in [str(self.REQUEST['AUTHENTICATED_USER'])]: @@ -307,7 +310,7 @@ class versionedFile(Folder): else: return "Sorry, not locked by you! (%s,%s)"%(self.lockedBy,self.REQUEST['AUTHENTICATED_USER']) - security= ClassSecurityInfo() + security.declareProtected('AUTHENTICATED_USER','addVersionedFileObjectForm') def addVersionedFileObjectForm(self): @@ -321,7 +324,7 @@ class versionedFile(Folder): else: return "Sorry file is locked by somebody else" - def manage_addVersionedFileObject(self,id,vC,author,file='',title='',precondition='', content_type='',changeName='no',RESPONSE=None): + def manage_addVersionedFileObject(self,id,vC,author,file='',title='',precondition='', content_type='',changeName='no',newName='', RESPONSE=None): """add""" vC=self.REQUEST['vC'] @@ -330,6 +333,8 @@ class versionedFile(Folder): if changeName=="yes": self.title=file.filename[0:] + if not newName=='': + self.title=newName[0:] id="V%i"%self.getVersion()+"_"+self.title manage_addVersionedFileObject(self,id,vC,author,file,"V%i"%self.getVersion()+"_"+self.title,precondition, content_type) @@ -342,7 +347,7 @@ class versionedFile(Folder): def download(self): """download and lock""" - self.getLastVersion().content_type="octet/stream" + self.getLastVersion().content_type="application/octet-stream" self.REQUEST.RESPONSE.redirect(self.REQUEST['URL1']+'/'+self.getId()+'/'+self.getLastVersion().getId()) def downloadLocked(self): @@ -352,7 +357,7 @@ class versionedFile(Folder): if not self.lockedBy=="": return "cannot be locked because is already locked by %s"%self.lockedBy self.lockedBy=self.REQUEST['AUTHENTICATED_USER'] - self.getLastVersion().content_type="octet/stream" + self.getLastVersion().content_type="application/octet-stream" self.REQUEST.RESPONSE.redirect(self.REQUEST['URL1']+'/'+self.getId()+'/'+self.getLastVersion().getId()) def manage_addVersionedFileForm(self):