Diff for /versionedFile/extVersionedFile.py between versions 1.18 and 1.28

version 1.18, 2008/01/02 16:58:35 version 1.28, 2008/10/07 06:53:45
Line 514  class extVersionedFileFolder(Folder,ECHO Line 514  class extVersionedFileFolder(Folder,ECHO
                   
         # get new extVersionedFile          # get new extVersionedFile
         vf = self._newVersionedFile(id,title=id)          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)          # 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)          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)          # add file to this folder (this should do the indexing)
Line 613  class extVersionedFileObject(ExtFile): Line 613  class extVersionedFileObject(ExtFile):
         self.time = time          self.time = time
         self.author = author          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')      security.declarePublic('getTitle')
     def getTitle(self):      def getTitle(self):
Line 621  class extVersionedFileObject(ExtFile): Line 628  class extVersionedFileObject(ExtFile):
           
     def getData(self):      def getData(self):
         """returns object content (calls ExtFile.index_html)"""          """returns object content (calls ExtFile.index_html)"""
         return ExtFile.index_html(self)          #logging.debug("+++++++getData1:"+repr(self.get_filename()))
           filename = self.get_filename()
           #return ExtFile.index_html(self)
           return file(filename).read()
       
       def getFileName(self):
           """return filename"""
           return self.get_filename()
       
       def addToFile(self,filehandle):
           filehandle.write(self.getData())
           
       def addToFile2(self,filename):   
            str="cat %s > %s"%(self.get_filename(),filename)
            os.popen(str)
           
     security.declarePublic('getVComment')      security.declarePublic('getVComment')
     def getVComment(self):      def getVComment(self):
Line 685  class extVersionedFileObject(ExtFile): Line 706  class extVersionedFileObject(ExtFile):
     #self.REQUEST.RESPONSE.setHeader("Content-Length","str(len(txt)+1000)")      #self.REQUEST.RESPONSE.setHeader("Content-Length","str(len(txt)+1000)")
                   
         self.content_type="application/octet-stream"          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()          #txt=urllib.urlopen(self.absolute_url()).read()
         #self.REQUEST.RESPONSE.write(txt)          #self.REQUEST.RESPONSE.write(txt)
           
   
         #self.REQUEST.close()          #self.REQUEST.close()
           
       view = download
       
     security.declareProtected('AUTHENTICATED_USER','downloadLocked')          security.declareProtected('AUTHENTICATED_USER','downloadLocked')    
     def downloadLocked(self):      def downloadLocked(self):
         """download and lock"""          """download and lock"""
Line 788  class extVersionedFile(CatalogAware,Fold Line 812  class extVersionedFile(CatalogAware,Fold
         self.id=id          self.id=id
         self.title=title          self.title=title
         self.lockedBy=lockedBy          self.lockedBy=lockedBy
           if self.lockedBy is None:
               self.lockedBy = ''
         self.author=author          self.author=author
         self.lastVersionNumber=0          self.lastVersionNumber=0
         self.lastVersionId=None          self.lastVersionId=None
Line 887  class extVersionedFile(CatalogAware,Fold Line 913  class extVersionedFile(CatalogAware,Fold
           
     def getLockedBy(self):      def getLockedBy(self):
         """get locked by"""          """get locked by"""
           if self.lockedBy is None:
               self.lockedBy = ''
         return str(self.lockedBy)          return str(self.lockedBy)
           
     def getLastVersionNumber(self):      def getLastVersionNumber(self):
Line 919  class extVersionedFile(CatalogAware,Fold Line 947  class extVersionedFile(CatalogAware,Fold
         lv=None          lv=None
                   
         for v in self.objectValues(self.content_meta_type):          for v in self.objectValues(self.content_meta_type):
             logging.debug("getlastversion: check %s"%v.getId())              #logging.debug("getlastversion: check %s"%v.getId())
             if v.getVersionNumber() > tmp:              if v.getVersionNumber() > tmp:
                     tmp=v.getVersionNumber()                      tmp=v.getVersionNumber()
                     lv=v                      lv=v
                   
         logging.debug("getlastversion: got %s"%lv.getId())          #ogging.debug("getlastversion: got %s"%lv.getId())
         return lv          return lv
   
     def getContentObject(self):      def getContentObject(self):
Line 942  class extVersionedFile(CatalogAware,Fold Line 970  class extVersionedFile(CatalogAware,Fold
     security.declarePublic('getData')      security.declarePublic('getData')
     def getData(self):      def getData(self):
         """Returns the content of the last version"""          """Returns the content of the last version"""
           logging.debug("+++++++getData2")
         ob = self.getContentObject()          ob = self.getContentObject()
         if ob is not None:          if ob is not None:
             return ob.getData()              return ob.getData()
         else:          else:
             return None              return None
           
       security.declarePublic('view')
       def view(self,REQUEST=None,RESPONSE=None):
           """Returns the last version's view"""
           ob = self.getContentObject()
           if ob is not None:
               return ob.view(REQUEST=REQUEST,RESPONSE=RESPONSE)
           else:
               return None
       
     def diff(self,data):      def diff(self,data):
         """differenz between lastversion and data"""          """differenz between lastversion and data"""
         d=Differ()          d=Differ()
Line 1007  class extVersionedFile(CatalogAware,Fold Line 1045  class extVersionedFile(CatalogAware,Fold
         ret.sort(sortv)          ret.sort(sortv)
         return ret          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')         security.declareProtected('AUTHENTICATED_USER','forceunlock')   
     def forceunlock(self,RESPONSE=None):      def forceunlock(self,RESPONSE=None):
         """unlock"""          """unlock"""
Line 1128  class extVersionedFile(CatalogAware,Fold Line 1179  class extVersionedFile(CatalogAware,Fold
                 return pt()                  return pt()
   
             else:              else:
                 RESPONSE.redirect(self.REQUEST['URL2'])                  RESPONSE.redirect(self.absolute_url()+'/history')
         else:          else:
             return ob              return ob
   
Line 1155  class extVersionedFile(CatalogAware,Fold Line 1206  class extVersionedFile(CatalogAware,Fold
                   
     def download(self):      def download(self):
         """download"""          """download"""
         self.REQUEST.RESPONSE.setHeader("Content-Disposition","""attachement; filename=%s"""%self.getContentObject().getId())      
         self.REQUEST.RESPONSE.setHeader("Content-Type","application/octet-stream")          txt=self.REQUEST['URL1']+'/'+self.getId()+'/'+self.getContentObject().getId()+'/download'
         self.content_type="application/octet-stream"          
         self.REQUEST.RESPONSE.redirect(self.REQUEST['URL1']+'/'+self.getId()+'/'+self.getContentObject().getId())          self.REQUEST.RESPONSE.redirect(txt)
   
           
     security.declareProtected('AUTHENTICATED_USER','downloadLocked')          security.declareProtected('AUTHENTICATED_USER','downloadLocked')    

Removed from v.1.18  
changed lines
  Added in v.1.28


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>