Diff for /versionedFile/extVersionedFile.py between versions 1.5 and 1.6

version 1.5, 2007/06/25 11:05:03 version 1.6, 2007/08/31 13:31:20
Line 59  class generateDownloadZip: Line 59  class generateDownloadZip:
     tempfile.tempdir=tdir      tempfile.tempdir=tdir
   
         tmpPath=tempfile.mktemp()          tmpPath=tempfile.mktemp()
         tmpZip=tempfile.mktemp()+".gtz"          tmpZip=tempfile.mktemp()+".tgz"
         tmpFn=os.path.split(tmpZip)[1]          tmpFn=os.path.split(tmpZip)[1]
                   
         if not os.path.exists(tempfile.tempdir):          if not os.path.exists(tempfile.tempdir):
Line 90  class generateDownloadZip: Line 90  class generateDownloadZip:
             if c==")":              if c==")":
                 self.response+="<br>\n"                  self.response+="<br>\n"
                           
                   
   
           
         shutil.rmtree(tmpPath)          shutil.rmtree(tmpPath)
   
         self.response+="<p>finished<br>\n"          self.response+="<p>finished<br>\n"
Line 120  class generateDownloadZip: Line 117  class generateDownloadZip:
   
 class extVersionedFileFolder(Folder,ECHO_basis):  class extVersionedFileFolder(Folder,ECHO_basis):
     """Folder with versioned files"""      """Folder with versioned files"""
   
       
     meta_type = "extVersionedFileFolder"      meta_type = "extVersionedFileFolder"
   
     security= ClassSecurityInfo()      security= ClassSecurityInfo()
     security.declareProtected('AUTHENTICATED_USER','addFileForm')      security.declareProtected('AUTHENTICATED_USER','addFileForm')
   
     filesMetaType=['extVersionedFile']      filesMetaType=['extVersionedFile']
   
     if ECHO_basis:      if ECHO_basis:
         optTMP= Folder.manage_options+ECHO_basis.manage_options          optTMP= Folder.manage_options+ECHO_basis.manage_options
     else:      else:
Line 150  class extVersionedFileFolder(Folder,ECHO Line 147  class extVersionedFileFolder(Folder,ECHO
           
     def changeHistoryFileNames(self,positionVersionNum="front",RESPONSE=None):      def changeHistoryFileNames(self,positionVersionNum="front",RESPONSE=None):
         """change position of version num"""          """change position of version num"""
           
           
           
         versions=self.ZopeFind(self,obj_metatypes=['extVersionedFileObject'],search_sub=1)          versions=self.ZopeFind(self,obj_metatypes=['extVersionedFileObject'],search_sub=1)
                   
         if not (getattr(self,'positionVersionNum','front')==positionVersionNum):          if not (getattr(self,'positionVersionNum','front')==positionVersionNum):
Line 176  class extVersionedFileFolder(Folder,ECHO Line 170  class extVersionedFileFolder(Folder,ECHO
                     else:                      else:
                         id=tmp[0]+"_"+version[1].getId().split("_")[0]                          id=tmp[0]+"_"+version[1].getId().split("_")[0]
                                   
                   
                   
                 version[1].aq_parent.manage_renameObjects(ids=[version[1].getId()],new_ids=[id])                  version[1].aq_parent.manage_renameObjects(ids=[version[1].getId()],new_ids=[id])
                 version[1].title=id                  version[1].title=id
                                   
                   
         self.positionVersionNum=positionVersionNum                  self.positionVersionNum=positionVersionNum        
         if RESPONSE:          if RESPONSE:
             RESPONSE.redirect("manage_main")              RESPONSE.redirect("manage_main")
Line 327  class extVersionedFileFolder(Folder,ECHO Line 318  class extVersionedFileFolder(Folder,ECHO
   
     def generateIndexHTML(self,RESPONSE=None):      def generateIndexHTML(self,RESPONSE=None):
         """lege standard index.html an"""          """lege standard index.html an"""
   
   
         if not self.ZopeFind(self,obj_ids=['index.html']):          if not self.ZopeFind(self,obj_ids=['index.html']):
             zt=ZopePageTemplate('index.html')              zt=ZopePageTemplate('index.html')
             self._setObject('index.html',zt)              self._setObject('index.html',zt)
Line 346  class extVersionedFileFolder(Folder,ECHO Line 335  class extVersionedFileFolder(Folder,ECHO
   
     def generateHistoryHTML(self,RESPONSE=None):      def generateHistoryHTML(self,RESPONSE=None):
         """lege standard index.html an"""          """lege standard index.html an"""
   
           
   
         if not self.ZopeFind(self,obj_ids=['history_template.html']):          if not self.ZopeFind(self,obj_ids=['history_template.html']):
             zt=ZopePageTemplate('history_template.html')              zt=ZopePageTemplate('history_template.html')
             self._setObject('history_template.html',zt)              self._setObject('history_template.html',zt)
Line 364  class extVersionedFileFolder(Folder,ECHO Line 350  class extVersionedFileFolder(Folder,ECHO
             RESPONSE.redirect('manage_main')              RESPONSE.redirect('manage_main')
   
           
          
   
     def getVersionedFiles(self,sortField='title'):      def getVersionedFiles(self,sortField='title'):
         """get all versioned files"""          """get all versioned files"""
   
Line 375  class extVersionedFileFolder(Folder,ECHO Line 359  class extVersionedFileFolder(Folder,ECHO
         def sortDate(x,y):          def sortDate(x,y):
             return cmp(y[1].getLastVersion().getTime(),x[1].getLastVersion().getTime())              return cmp(y[1].getLastVersion().getTime(),x[1].getLastVersion().getTime())
   
           
         def sortComment(x,y):          def sortComment(x,y):
   
           
               
      try:       try:
         xc=getattr(x[1],'comment','ZZZZZZZZZZZZZ').lower()          xc=getattr(x[1],'comment','ZZZZZZZZZZZZZ').lower()
      except:       except:
         xc='ZZZZZZZZZZZZZ'.lower()          xc='ZZZZZZZZZZZZZ'.lower()
                   
      try:       try:
         yc=getattr(y[1],'comment','ZZZZZZZZZZZZZ').lower()          yc=getattr(y[1],'comment','ZZZZZZZZZZZZZ').lower()
          except:           except:
             yc='ZZZZZZZZZZZZZ'.lower()              yc='ZZZZZZZZZZZZZ'.lower()
   
   
          if (xc=='') or (xc=='ZZZZZZZZZZZZZ'.lower()):           if (xc=='') or (xc=='ZZZZZZZZZZZZZ'.lower()):
                
              try:               try:
                  xc=x[1].getLastVersion().getVComment().lower()                   xc=x[1].getLastVersion().getVComment().lower()
              except:               except:
Line 403  class extVersionedFileFolder(Folder,ECHO Line 382  class extVersionedFileFolder(Folder,ECHO
              except:               except:
                  yc='ZZZZZZZZZZZZZ'.lower()                   yc='ZZZZZZZZZZZZZ'.lower()
   
            
          return cmp(xc,yc)           return cmp(xc,yc)
   
         def sortAuthor(x,y):          def sortAuthor(x,y):
Line 412  class extVersionedFileFolder(Folder,ECHO Line 390  class extVersionedFileFolder(Folder,ECHO
                   
         versionedFiles=self.ZopeFind(self,obj_metatypes=self.filesMetaType)          versionedFiles=self.ZopeFind(self,obj_metatypes=self.filesMetaType)
                   
           
         if sortField=='title':          if sortField=='title':
             versionedFiles.sort(sortName)              versionedFiles.sort(sortName)
         elif sortField=='date':          elif sortField=='date':
Line 545  class extVersionedFileObject(ExtFile): Line 522  class extVersionedFileObject(ExtFile):
                                Kind='File',kind='file')                                 Kind='File',kind='file')
     manage_editForm._setName('manage_editForm')      manage_editForm._setName('manage_editForm')
   
   
       
    
     security.declarePublic('getTitle')      security.declarePublic('getTitle')
   
     def getTitle(self):      def getTitle(self):
         """get title"""          """get title"""
         return self.title          return self.title
     
       def getData(self):
           """returns object content (calls ExtFile.index_html)"""
           return ExtFile.index_html(self)
       
     security.declarePublic('getVComment')      security.declarePublic('getVComment')
     def getVComment(self):      def getVComment(self):
         """get the comment of this file"""          """get the comment of this file"""
Line 567  class extVersionedFileObject(ExtFile): Line 544  class extVersionedFileObject(ExtFile):
         """add a comment"""          """add a comment"""
   
         self.REQUEST.SESSION['refer']=self.REQUEST['HTTP_REFERER']          self.REQUEST.SESSION['refer']=self.REQUEST['HTTP_REFERER']
   
   
           
         pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','addVComment')).__of__(self)          pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','addVComment')).__of__(self)
         return pt()          return pt()
   
Line 652  class extVersionedFileObject(ExtFile): Line 626  class extVersionedFileObject(ExtFile):
   
   
     security.declarePublic('getVersionNumber')                                                    security.declarePublic('getVersionNumber')                                              
   
     def getVersionNumber(self):      def getVersionNumber(self):
         """get version"""          """get version"""
         return self.versionNumber          return self.versionNumber
Line 665  class extVersionedFileObject(ExtFile): Line 638  class extVersionedFileObject(ExtFile):
         
   
     security.declarePublic('lastEditor')                                                      security.declarePublic('lastEditor')                                                
   
     def lastEditor(self):      def lastEditor(self):
         """last Editor"""          """last Editor"""
         if hasattr(self,'author'):          if hasattr(self,'author'):
Line 685  class extVersionedFileObject(ExtFile): Line 657  class extVersionedFileObject(ExtFile):
             return jar.db().history(oid)[0]['user_name']              return jar.db().history(oid)[0]['user_name']
   
           
       
           
 manage_addextVersionedFileObjectForm=DTMLFile('dtml/fileAdd', globals(),Kind='extVersionedFileObject',kind='extVersionedFileObject', version='1')  manage_addextVersionedFileObjectForm=DTMLFile('dtml/fileAdd', globals(),Kind='extVersionedFileObject',kind='extVersionedFileObject', version='1')
   
 def manage_addextVersionedFileObject(self,id,vC='',author='', file='',title='',precondition='', content_type='',  def manage_addextVersionedFileObject(self,id,vC='',author='', file='',title='',precondition='', content_type='',
Line 850  class extVersionedFile(CatalogAware,Fold Line 820  class extVersionedFile(CatalogAware,Fold
         tmp=0          tmp=0
         lastVersion=None          lastVersion=None
                   
           
         for version in self.ZopeFind(self):          for version in self.ZopeFind(self):
                           
             if hasattr(version[1],'versionNumber'):              if hasattr(version[1],'versionNumber'):
Line 881  class extVersionedFile(CatalogAware,Fold Line 850  class extVersionedFile(CatalogAware,Fold
             if a[0]=='-':              if a[0]=='-':
                 minus+=1                  minus+=1
                   
           
         return max([plus,minus]),l          return max([plus,minus]),l
   
   
     security.declarePublic('index_html')      security.declarePublic('index_html')
     def index_html(self):      def index_html(self):
         """main view"""          """main view"""
Line 904  class extVersionedFile(CatalogAware,Fold Line 874  class extVersionedFile(CatalogAware,Fold
         return tmp+1          return tmp+1
   
   
     security.declareProtected('AUTHENTICATED_USER','unlock')  
   
     def history(self):      def history(self):
         """history"""            """history"""  
   
Line 948  class extVersionedFile(CatalogAware,Fold Line 916  class extVersionedFile(CatalogAware,Fold
   
           
     security.declareProtected('AUTHENTICATED_USER','addVersionedFileObjectForm')      security.declareProtected('AUTHENTICATED_USER','addVersionedFileObjectForm')
   
     def addVersionedFileObjectForm(self):      def addVersionedFileObjectForm(self):
         """add a new version"""          """add a new version"""
                   
Line 980  class extVersionedFile(CatalogAware,Fold Line 947  class extVersionedFile(CatalogAware,Fold
                         filename.rfind(':'),                          filename.rfind(':'),
                         )+1:]                          )+1:]
   
   
         if not newName=='':          if not newName=='':
             self.title=newName[0:]              self.title=newName[0:]
                   
           
   
           
           
         positionVersionNum=getattr(self,'positionVersionNum','front')          positionVersionNum=getattr(self,'positionVersionNum','front')
                   
         if positionVersionNum=='front':          if positionVersionNum=='front':
Line 999  class extVersionedFile(CatalogAware,Fold Line 961  class extVersionedFile(CatalogAware,Fold
             else:              else:
                 id=tmp[0]+"_V%i"%self.getVersion()                  id=tmp[0]+"_V%i"%self.getVersion()
                           
           
         manage_addextVersionedFileObject(self,id,vC,author,file,id,precondition, content_type)          manage_addextVersionedFileObject(self,id,vC,author,file,id,precondition, content_type)
         objs=self.ZopeFind(self,obj_ids=[id])[0][1].setVersionNumber(int(self.getVersion()))          objs=self.ZopeFind(self,obj_ids=[id])[0][1].setVersionNumber(int(self.getVersion()))
         self.REQUEST.SESSION['objID_parent']=self.getId()          self.REQUEST.SESSION['objID_parent']=self.getId()
Line 1021  class extVersionedFile(CatalogAware,Fold Line 982  class extVersionedFile(CatalogAware,Fold
         else:          else:
             return self.ZopeFind(self,obj_ids=[id])[0][1]              return self.ZopeFind(self,obj_ids=[id])[0][1]
                   
     security.declareProtected('AUTHENTICATED_USER','downloadLocked')  
   
     def download(self):      def download(self):
         """download and lock"""          """download and lock"""
   
         self.REQUEST.RESPONSE.setHeader("Content-Disposition","""attachement; filename=%s"""%self.getLastVersion().getId())          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.content_type="application/octet-stream"
         #self.REQUEST.RESPONSE.write("bl")  
         #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())
           
     security.declareProtected('AUTHENTICATED_USER','downloadLocked')          security.declareProtected('AUTHENTICATED_USER','downloadLocked')    

Removed from v.1.5  
changed lines
  Added in v.1.6


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