Diff for /versionedFile/extVersionedFile.py between versions 1.29 and 1.33

version 1.29, 2008/10/09 07:44:34 version 1.33, 2009/06/24 11:24:05
Line 3  using the ExtFile Product, this version Line 3  using the ExtFile Product, this version
 DW 11.10.2006  DW 11.10.2006
 """  """
   
   import email
 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 142  class extVersionedFileFolder(Folder,ECHO Line 143  class extVersionedFileFolder(Folder,ECHO
         )          )
   
           
       def redirect(self,RESPONSE,url):
           """mache ein redirect mit einem angehaengten time stamp um ein reload zu erzwingen"""
           
           timeStamp=time.time()
           
           if url.find("?")>-1: #giebt es schon parameter
               addStr="&time=%s"
           else:
               addStr="?time=%s"
               
           RESPONSE.setHeader('Last-Modified',email.Utils.formatdate().split("-")[0]+'GMT')
           logging.error(email.Utils.formatdate()+' GMT')
           RESPONSE.redirect(url+addStr%timeStamp)
     def changeHistoryFileNamesForm(self):      def changeHistoryFileNamesForm(self):
         """change position of version num"""          """change position of version num"""
         pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','changeHistoryFileNamesForm.zpt')).__of__(self)          pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','changeHistoryFileNamesForm.zpt')).__of__(self)
Line 632  class extVersionedFileObject(ExtFile): Line 646  class extVersionedFileObject(ExtFile):
         filename = self.get_filename()          filename = self.get_filename()
         #return ExtFile.index_html(self)          #return ExtFile.index_html(self)
         try:          try:
               logging.info("readfile:"+filename)
             return file(filename).read()              return file(filename).read()
         except:          except:
               logging.info("cannot readfile:"+filename)
             return ExtFile.index_html(self)              return ExtFile.index_html(self)
   
           
Line 1018  class extVersionedFile(CatalogAware,Fold Line 1034  class extVersionedFile(CatalogAware,Fold
         #return "File: %s Version:%i modified:%s size:%s modified by:%s"%(self.title,lastVersion.versionNumber,lastVersion.getTime(),lastVersion.getSize(),lastVersion.lastEditor())          #return "File: %s Version:%i modified:%s size:%s modified by:%s"%(self.title,lastVersion.versionNumber,lastVersion.getTime(),lastVersion.getSize(),lastVersion.lastEditor())
         return self.history()          return self.history()
   
       def getVersionNr(self,nr):
           """get version with number nr"""
           tmp=0
           lastVersion=None
           
           
           for version in self.ZopeFind(self):
               
               if hasattr(version[1],'versionNumber'):
           
                   if int(version[1].versionNumber) ==nr :
                       return version[1]
              
           return None
     security.declarePublic('getVersion')                                                    security.declarePublic('getVersion')                                              
     def getVersion(self):      def getVersion(self):
         # TODO: this is ugly and it returns the next version number           # TODO: this is ugly and it returns the next version number 
Line 1063  class extVersionedFile(CatalogAware,Fold Line 1092  class extVersionedFile(CatalogAware,Fold
         return vl          return vl
   
     security.declareProtected('AUTHENTICATED_USER','forceunlock')         security.declareProtected('AUTHENTICATED_USER','forceunlock')   
     def forceunlock(self,RESPONSE=None):      def forceunlock(self,RESPONSE=None,user=None):
         """unlock"""          """unlock"""
         #safe who had the lock          #safe who had the lock
           logging.debug("extVersionFile: (forceunlock)"+str(user))
         if self.lockedBy:          if self.lockedBy:
               if user is not None:
                   if str(self.lockedBy)==user:
             self.brokenLock=str(self.lockedBy)              self.brokenLock=str(self.lockedBy)
                       self.lockedBy=''
         else:          else:
             self.brokenLock=""              self.brokenLock=""
               else:
                   self.brokenLock=str(self.lockedBy)
         self.lockedBy=''          self.lockedBy=''
           else:
               self.brokenLock=""
           
         return self.brokenLock          return self.brokenLock
   
     security.declareProtected('AUTHENTICATED_USER','unlock')         security.declareProtected('AUTHENTICATED_USER','unlock')   
Line 1083  class extVersionedFile(CatalogAware,Fold Line 1121  class extVersionedFile(CatalogAware,Fold
             return "Sorry, not locked by you! (%s,%s)"%(self.lockedBy,self.REQUEST['AUTHENTICATED_USER'])              return "Sorry, not locked by you! (%s,%s)"%(self.lockedBy,self.REQUEST['AUTHENTICATED_USER'])
                   
           
   
     def _newContentObject(self, id, title='', versionNumber=0, versionComment=None, time=None, author=None):      def _newContentObject(self, id, title='', versionNumber=0, versionComment=None, time=None, author=None):
         """factory for content objects. to be overridden in derived classes."""          """factory for content objects. to be overridden in derived classes."""
         return extVersionedFileObject(id,title,versionNumber=versionNumber,versionComment=versionComment,time=time,author=author)          return extVersionedFileObject(id,title,versionNumber=versionNumber,versionComment=versionComment,time=time,author=author)

Removed from v.1.29  
changed lines
  Added in v.1.33


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