Diff for /versionedFile/versionedFile.py between versions 1.50 and 1.55

version 1.50, 2005/11/02 12:38:52 version 1.55, 2005/12/08 17:12:21
Line 1 Line 1
   
 from OFS.Folder import Folder  from OFS.Folder import Folder
 from OFS.Image import File  from OFS.Image import File
 from OFS.Image import cookId  from OFS.Image import cookId
Line 8  from AccessControl import getSecurityMan Line 7  from AccessControl import getSecurityMan
 from Products.PageTemplates.PageTemplate import PageTemplate  from Products.PageTemplates.PageTemplate import PageTemplate
 from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate  from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
 from AccessControl import ClassSecurityInfo  from AccessControl import ClassSecurityInfo
 <<<<<<< versionedFile.py  from difflib import Differ
 from Products.ImageArchive.ImageArchive import manage_AddImageZogiLib  from pprint import pprint
   
 from Products.ZCatalog.CatalogPathAwareness import CatalogAware  from Products.ZCatalog.CatalogPathAwareness import CatalogAware
 =======  
 try:  try:
  from Products.ImageArchive.ImageArchive import manage_AddImageZogiLib   from Products.ImageArchive.ImageArchive import manage_AddImageZogiLib
 except:  except:
  print "no images"   print "no images"
 >>>>>>> 1.49  
   
 from threading import Thread  from threading import Thread
 import shutil  import shutil
Line 133  class versionedFileFolder(Folder,ECHO_ba Line 133  class versionedFileFolder(Folder,ECHO_ba
                 {'label':'Generate history_template.html','action':'generateHistoryHTML'},                  {'label':'Generate history_template.html','action':'generateHistoryHTML'},
                 {'label':'Import Folder','action':'importFolderForm'},                  {'label':'Import Folder','action':'importFolderForm'},
                 {'label':'Export Folder','action':'exportFolder'},                  {'label':'Export Folder','action':'exportFolder'},
                   {'label':'Position of version number','action':'changeHistoryFileNamesForm'},
                 )                  )
   
       def changeHistoryFileNamesForm(self):
           """change position of version num"""
           pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','changeHistoryFileNamesForm.zpt')).__of__(self)
           return pt()
       
       
       def changeHistoryFileNames(self,positionVersionNum="front",RESPONSE=None):
           """change position of version num"""
           
           
           
           versions=self.ZopeFind(self,obj_metatypes=['versionedFileObject'],search_sub=1)
           
           if not (getattr(self,'positionVersionNum','front')==positionVersionNum):
   
               for version in versions:
                                   
                   if positionVersionNum=="front":
           
                       titleTmp=os.path.splitext(version[1].title)
                       titleTmp2="_".join(titleTmp[0].split("_")[0:-1])
                       if len(titleTmp)>1:
                           id=titleTmp[0].split("_")[-1]+"_"+titleTmp2+"."+titleTmp[1]
                       else:
                           id=titleTmp[0].split("_")[-1]+"_"+titleTmp2
   
                   else:
                       titleTmp="_".join(version[1].getId().split("_")[1:])
                       tmp=os.path.splitext(titleTmp)
                       if len(tmp)>1:
                           id=tmp[0]+"_"+version[1].getId().split("_")[0]+tmp[1]
                       else:
                           id=tmp[0]+"_"+version[1].getId().split("_")[0]
                   
                   
                   
                   version[1].aq_parent.manage_renameObjects(ids=[version[1].getId()],new_ids=[id])
                   version[1].title=id
                   
                   
           self.positionVersionNum=positionVersionNum        
           if RESPONSE:
               RESPONSE.redirect("manage_main")
           
           
           
     def importFolderForm(self):      def importFolderForm(self):
         """form fuer folder import"""          """form fuer folder import"""
         pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','importFolderForm.zpt')).__of__(self)          pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','importFolderForm.zpt')).__of__(self)
Line 469  class versionedFileObject(File): Line 516  class versionedFileObject(File):
     manage_editForm  =DTMLFile('dtml/fileEdit',globals(),      manage_editForm  =DTMLFile('dtml/fileEdit',globals(),
                                Kind='File',kind='file')                                 Kind='File',kind='file')
     manage_editForm._setName('manage_editForm')      manage_editForm._setName('manage_editForm')
 <<<<<<< versionedFile.py  
   
     security.declarePublic('getVComment')      security.declarePublic('getVComment')
 =======  
     security= ClassSecurityInfo()  
   
 >>>>>>> 1.49  
     def getVComment(self):      def getVComment(self):
         """get the comment of this file"""          """get the comment of this file"""
         if not hasattr(self,'vComment') or (not self.vComment) or (self.vComment.lstrip()==""):          if not hasattr(self,'vComment') or (not self.vComment) or (self.vComment.lstrip()==""):
Line 510  class versionedFileObject(File): Line 554  class versionedFileObject(File):
             return REQUEST.RESPONSE.redirect(self.REQUEST.SESSION['refer'])              return REQUEST.RESPONSE.redirect(self.REQUEST.SESSION['refer'])
         return REQUEST.RESPONSE.redirect(self.aq_parent.absolute_url()+"/history")          return REQUEST.RESPONSE.redirect(self.aq_parent.absolute_url()+"/history")
           
 <<<<<<< versionedFile.py  
     security.declarePublic('getVersionComment')      security.declarePublic('getVersionComment')
     def getVersionComment(self):      def getVersionComment(self):
         """getversioncomment"""          """getversioncomment"""
         return self.versionComment          return self.versionComment
           
     security.declarePublic('getTime')      security.declarePublic('getTime')
 =======  
     security.declarePublic('getTime')                                                
 >>>>>>> 1.49  
     def getTime(self):      def getTime(self):
         """getTime"""          """getTime"""
         #return self.bobobase_modification_time().ISO()          #return self.bobobase_modification_time().ISO()
Line 572  class versionedFileObject(File): Line 614  class versionedFileObject(File):
         """set version"""          """set version"""
         self.versionNumber=versionNumber          self.versionNumber=versionNumber
   
 <<<<<<< versionedFile.py  
   
     security.declarePublic('getVersionNumber')      security.declarePublic('getVersionNumber')
 =======  
     security.declarePublic('getVersionNumber')                                                
 >>>>>>> 1.49  
     def getVersionNumber(self):      def getVersionNumber(self):
         """get version"""          """get version"""
         return self.versionNumber          return self.versionNumber
Line 588  class versionedFileObject(File): Line 627  class versionedFileObject(File):
         return self.versionComment          return self.versionComment
   
         
 <<<<<<< versionedFile.py  
     security.declarePublic('lastEditor')           
 =======  
     security.declarePublic('lastEditor')                                                      security.declarePublic('lastEditor')                                                
 >>>>>>> 1.49  
     def lastEditor(self):      def lastEditor(self):
         """last Editor"""          """last Editor"""
         if hasattr(self,'author'):          if hasattr(self,'author'):
               try:
             ret=self.author.replace("-","\n")              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")              ret=ret.replace("\r","\n")
             return ret              return ret
   
Line 761  class versionedFile(CatalogAware,Folder) Line 801  class versionedFile(CatalogAware,Folder)
                 lastVersion.versionNumber=1                  lastVersion.versionNumber=1
         return lastVersion          return lastVersion
           
       
       def diff(self,data):
           """differenz between lastversion and data"""
           d=Differ()
           tmp=self.getLastVersion().data
           #print "XX",data,tmp
           l=list(d.compare(data.splitlines(1),tmp.splitlines(1)))
           
           plus=0
           minus=0
           for a in l:
               if a[0]=='+':
                   plus+=1
               if a[0]=='-':
                   minus+=1
           
           
           return max([plus,minus]),l
       
     def index_html(self):      def index_html(self):
         """main view"""          """main view"""
         lastVersion=self.getLastVersion()          lastVersion=self.getLastVersion()
Line 848  class versionedFile(CatalogAware,Folder) Line 907  class versionedFile(CatalogAware,Folder)
   
         if not newName=='':          if not newName=='':
             self.title=newName[0:]              self.title=newName[0:]
         print self.title  
                   
           
   
           
           
           positionVersionNum=getattr(self,'positionVersionNum','front')
           
           if positionVersionNum=='front':
         id="V%i"%self.getVersion()+"_"+self.title          id="V%i"%self.getVersion()+"_"+self.title
           else:
               tmp=os.path.splitext(self.title)
               if len(tmp)>1:
                   id=tmp[0]+"_V%i"%self.getVersion()+tmp[1]
               else:
                   id=tmp[0]+"_V%i"%self.getVersion()
               
                   
         manage_addVersionedFileObject(self,id,vC,author,file,"V%i"%self.getVersion()+"_"+self.title,precondition, content_type)          manage_addVersionedFileObject(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()
   

Removed from v.1.50  
changed lines
  Added in v.1.55


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