--- versionedFile/extVersionedFile.py 2008/01/21 17:36:45 1.19 +++ versionedFile/extVersionedFile.py 2008/08/19 14:43:25 1.26 @@ -514,7 +514,7 @@ class extVersionedFileFolder(Folder,ECHO # get new extVersionedFile vf = self._newVersionedFile(id,title=id) - logging.debug("addFile id=%s vf=%s of %s"%(repr(id),repr(vf),repr(self))) + logging.error("addFile id=%s vf=%s of %s"%(repr(id),repr(vf),repr(self))) # add its content (and don't index) obj=vf.addContentObject(id,vC,author=author,file=file,content_type=content_type,from_tmp=isRealFile,index=False) # add file to this folder (this should do the indexing) @@ -613,6 +613,13 @@ class extVersionedFileObject(ExtFile): self.time = time self.author = author + security.declareProtected('manage','changeObject') + def changeObject(self,**args): + """modify any of the objects attributes""" + for arg in args: + if hasattr(self, arg): + logging.debug("changeObject %s: %s=%s"%(repr(self),arg,args[arg])) + setattr(self, arg, args[arg]) security.declarePublic('getTitle') def getTitle(self): @@ -685,7 +692,8 @@ class extVersionedFileObject(ExtFile): #self.REQUEST.RESPONSE.setHeader("Content-Length","str(len(txt)+1000)") self.content_type="application/octet-stream" - self.REQUEST.RESPONSE.redirect(self.absolute_url()) + return self.getData() + #self.REQUEST.RESPONSE.redirect(self.absolute_url()) #txt=urllib.urlopen(self.absolute_url()).read() #self.REQUEST.RESPONSE.write(txt) @@ -790,6 +798,8 @@ class extVersionedFile(CatalogAware,Fold self.id=id self.title=title self.lockedBy=lockedBy + if self.lockedBy is None: + self.lockedBy = '' self.author=author self.lastVersionNumber=0 self.lastVersionId=None @@ -889,6 +899,8 @@ class extVersionedFile(CatalogAware,Fold def getLockedBy(self): """get locked by""" + if self.lockedBy is None: + self.lockedBy = '' return str(self.lockedBy) def getLastVersionNumber(self): @@ -1018,6 +1030,19 @@ class extVersionedFile(CatalogAware,Fold ret.sort(sortv) return ret + def getVersionList(self): + """get a list of dicts with author, comment, filename, etc, of all versions""" + vl = [] + for v in self.objectValues(self.content_meta_type): + vl.append({'versionNumber':getattr(v,'versionNumber',0), + 'title':v.getTitle(), + 'id':v.getId(), + 'date':v.getTime(), + 'author':getattr(v,'author',''), + 'comment':getattr(v,'versionComment','') + }) + return vl + security.declareProtected('AUTHENTICATED_USER','forceunlock') def forceunlock(self,RESPONSE=None): """unlock""" @@ -1166,10 +1191,10 @@ class extVersionedFile(CatalogAware,Fold def download(self): """download""" - self.REQUEST.RESPONSE.setHeader("Content-Disposition","""attachement; filename=%s"""%self.getContentObject().getId()) - self.REQUEST.RESPONSE.setHeader("Content-Type","application/octet-stream") - self.content_type="application/octet-stream" - self.REQUEST.RESPONSE.redirect(self.REQUEST['URL1']+'/'+self.getId()+'/'+self.getContentObject().getId()) + + txt=self.REQUEST['URL1']+'/'+self.getId()+'/'+self.getContentObject().getId()+'/download' + + self.REQUEST.RESPONSE.redirect(txt) security.declareProtected('AUTHENTICATED_USER','downloadLocked')