Diff for /cdli/cdli_files.py between versions 1.107 and 1.114

version 1.107, 2009/06/05 07:30:11 version 1.114, 2009/09/01 08:36:04
Line 343  def splitatf(fh,dir=None,ext=None): Line 343  def splitatf(fh,dir=None,ext=None):
     for lineTmp in iter:      for lineTmp in iter:
         lineTmp=lineTmp.replace(codecs.BOM_UTF8,'') # make sure that all BOM are removed..          lineTmp=lineTmp.replace(codecs.BOM_UTF8,'') # make sure that all BOM are removed..
         for line in lineTmp.split("\r"):          for line in lineTmp.split("\r"):
             #logging.log("Deal with: %s"%line)              #logging.info("Deal with: %s"%line)
             if ext:              if ext:
                 i+=1                  i+=1
                 if (i%100)==0:                  if (i%100)==0:
Line 721  class CDLIRoot(Folder): Line 721  class CDLIRoot(Folder):
     splitter = {'words':cdliSplitter.wordSplitter(),      splitter = {'words':cdliSplitter.wordSplitter(),
                 'graphemes':cdliSplitter.graphemeSplitter()}                  'graphemes':cdliSplitter.graphemeSplitter()}
           
       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 unicodify(self,txt):      def unicodify(self,txt):
         return unicodify(txt)          return unicodify(txt)
Line 756  class CDLIRoot(Folder): Line 769  class CDLIRoot(Folder):
         """view an Object"""          """view an Object"""
         ob = self.CDLICatalog({'title':id})          ob = self.CDLICatalog({'title':id})
         if len(ob)>0:          if len(ob)>0:
             RESPONSE.redirect(ob[0].getLastVersion().absolute_url())              logging.info("objekt:"+repr(ob[0]))
               #RESPONSE.redirect(ob[0].getLastVersion().absolute_url())
               RESPONSE.redirect(ob[0].absolute_url+"/download")
         return "not found"          return "not found"
     def addCDLIFileObjectForm(self,id,RESPONSE):      def addCDLIFileObjectForm(self,id,RESPONSE):
         """view an Object"""          """view an Object"""
Line 779  class CDLIRoot(Folder): Line 794  class CDLIRoot(Folder):
             RESPONSE.redirect(ob[0].absolute_url+"/unlock")              RESPONSE.redirect(ob[0].absolute_url+"/unlock")
         return "not found"          return "not found"
           
       
     def getFileObject(self,fileId):      def getFileObject(self,fileId):
         """get an object"""          """get an object"""
           logging.debug("getFileObj:"+repr(fileId))
           if isinstance(fileId,CDLIFileObject): # support for old baskets
                     return fileId
         x=self.v_files.get(fileId)          x=self.v_files.get(fileId)
         #logging.debug(x)          logging.debug("obj: "+repr(x))
           if x==None:
               folder=fileId[0:3]
               f2=fileId[0:5]
               fObj = getattr(self.cdliRoot.cdli_main,folder);
               f2Obj = getattr(fObj,f2)
               
               o = getattr(f2Obj,fileId)
               logging.debug(o);
               self.updateOrAddToFileBTree(o)
               return o
         return x          return x
           
     def getFileObjectLastVersion(self,fileId):      def getFileObjectLastVersion(self,fileId):
         """get an object"""          """get an object"""
         x=self.v_files_lastVersion.get(fileId)          x=self.v_files_lastVersion.get(fileId)
         #logging.debug("lastVersion: "+repr(x))          logging.debug("lastVersion: "+repr(x))
           if x==None:
               folder=fileId[0:3]
               f2=fileId[0:5]
               fObj = getattr(self.cdliRoot.cdli_main,folder);
               f2Obj = getattr(fObj,f2)
   
               o =getattr(f2Obj,fileId)
               logging.debug(o);
               return o.getLastVersion()
           
   
         return x          return x
           
     def showFileIds(self):      def showFileIds(self):
Line 817  class CDLIRoot(Folder): Line 857  class CDLIRoot(Folder):
         self.v_files_lastVersion.update({obj.getId():obj.getLastVersion()})          self.v_files_lastVersion.update({obj.getId():obj.getLastVersion()})
                   
         self.v_file_ids.add(obj.getId())          self.v_file_ids.add(obj.getId())
           #change everthing around to make it persistent...
           tmp = self.v_files
           self.v_files=tmp
           
           tmp2=self.v_file_ids
           self.v_file_ids=tmp2
   
           self.CDLICache.cleanCache() #be sure that the cache is clean
         logging.debug("update:"+obj.getId()+"XXX"+repr(obj))          logging.debug("update:"+obj.getId()+"XXX"+repr(obj))
                   
   
     def deleteFromBTree(self,objId):      def deleteFromBTree(self,objId):
         """delete an obj"""          """delete an obj"""
         self.v_files.pop(objId)          self.v_files.pop(objId)
Line 1044  class CDLIRoot(Folder): Line 1093  class CDLIRoot(Folder):
           
                           
                   
                   gen
     def forceunlock(self,REQUEST=None,user=None):      def forceunlock(self,REQUEST=None,user=None,fid=None):
         "break all locks"          "break all locks"
           if fid is not None:
               self.getFileObject(fid).forceunlock()
               return fid
         ret=[]          ret=[]
                   
         for f in self.ZopeFind(self,obj_metatypes="CDLI file",search_sub=1):          for f in self.ZopeFind(self,obj_metatypes="CDLI file",search_sub=1):
Line 1067  class CDLIRoot(Folder): Line 1119  class CDLIRoot(Folder):
         """hole alle gesperrten files"""          """hole alle gesperrten files"""
         ret={}          ret={}
           
         for f in self.ZopeFind(self,obj_metatypes="CDLI file",search_sub=1):          for nm,f in self.v_files.items():
             lb = f[1].lockedBy              lb = str(f.lockedBy)
             add=False              add=False
             if (lb is not None) and (lb!=""):              if (lb is not None) and (lb!=""):
                                 
Line 1080  class CDLIRoot(Folder): Line 1132  class CDLIRoot(Folder):
                 if add==True:                  if add==True:
                     if not ret.has_key(lb):                      if not ret.has_key(lb):
                         ret[lb]=[]                          ret[lb]=[]
                     ret[lb].append(f[0])                      ret[lb].append(nm)
                   
                   
         if REQUEST is not None:          if REQUEST is not None:
Line 1327  class CDLIRoot(Folder): Line 1379  class CDLIRoot(Folder):
                     try:                      try:
                         self.cdliRoot.updateOrAddToFileBTree(ob[0].getObject())                          self.cdliRoot.updateOrAddToFileBTree(ob[0].getObject())
                     except:                      except:
                  
                         logging.error("uploadATFfinally - cannot update Object %s Error: %s %s"%(ob[1],sys.exc_info()[0],sys.exc_info()[1]))                          logging.error("uploadATFfinally - cannot update Object %s Error: %s %s"%(ob[1],sys.exc_info()[0],sys.exc_info()[1]))
                 for x in stObj.returnValue['newPs']:
                     obj=self.getFileObject(x) #updates the object in the cache
                     logging.debug("Got:"+repr(obj))
               if RESPONSE is not None:                if RESPONSE is not None:
                   RESPONSE.redirect(self.absolute_url())                    RESPONSE.redirect(self.absolute_url())
   
Line 1374  class CDLIRoot(Folder): Line 1430  class CDLIRoot(Folder):
             id=f              id=f
             logging.debug("importFiles: addCDLIFile fobj2=%s, f=%s file2=%s"%(fobj2,repr(f),repr(file2)))              logging.debug("importFiles: addCDLIFile fobj2=%s, f=%s file2=%s"%(fobj2,repr(f),repr(file2)))
             fobj2.addFile(vC='',file=file(file2),author=author,newName=f)              fobj2.addFile(vC='',file=file(file2),author=author,newName=f)
               logging.debug("importfiles: fobj2.add")
             count+=1              count+=1
                           
             #now add the file to the storage              #now add the file to the storage
             ob = getattr(fobj2,f)              ob = getattr(fobj2,f)
             self.cdliRoot.updateOrAddToFileBTree(ob)              logging.debug("importfiles: btree_start")
                           #self.cdliRoot.updateOrAddToFileBTree(ob)
               logging.debug("importfiles: btree_end")
             if count%100==0:              if count%100==0:
                 logging.debug("importfiles: committing")                  logging.debug("importfiles: committing")
                 transaction.get().commit()                  transaction.get().commit()
   
           logging.debug("importfiles: committing")
         transaction.get().commit()          transaction.get().commit()
           logging.debug("importfiles: committing done")
         return "ok"          return "ok"
                     
   

Removed from v.1.107  
changed lines
  Added in v.1.114


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