Diff for /cdli/cdli_files.py between versions 1.22 and 1.25

version 1.22, 2006/06/14 18:43:38 version 1.25, 2006/06/15 22:02:40
Line 214  class uploadATFThread(Thread): Line 214  class uploadATFThread(Thread):
         app  = root['Application']          app  = root['Application']
         ctx = self.getContext(app,serverport=self.serverport)          ctx = self.getContext(app,serverport=self.serverport)
         self.uploadATFThread(ctx,self.upload,self.basketId)          self.uploadATFThread(ctx,self.upload,self.basketId)
         ctx.cdliRoot.cdli_main.tmpStore=self.returnValue       
           ctx.cdliRoot.cdli_main.tmpStore2[self.getName()[0:]]=self.returnValue
   
         get_transaction().commit()          get_transaction().commit()
                   
         while self.continueVar:          while self.continueVar:
Line 231  class uploadATFThread(Thread): Line 233  class uploadATFThread(Thread):
         """upload an atf file"""          """upload an atf file"""
         #TODO: add comments          #TODO: add comments
         #TODO: finish uploadATF          #TODO: finish uploadATF
         self.result="<html><body><h2>I am loading your file...</h2>"          self.result="<html><body><h2>I got your file, start now to split it into single atf-files!</h2><p>"
       
         #make sure that id is a string and not an integer          #make sure that id is a string and not an integer
         basketId=str(basketId)          basketId=str(basketId)
                   
Line 248  class uploadATFThread(Thread): Line 251  class uploadATFThread(Thread):
         psNotInCatalog=[] # files not in the catalog          psNotInCatalog=[] # files not in the catalog
                   
         #split the uploadedd atf file          #split the uploadedd atf file
         basketNameFromFile, numberOfFiles=splitatf(upload,dir)          basketNameFromFile, numberOfFiles=splitatf(upload,dir,ext=self)
                   
         #find basketId if not set          #find basketId if not set
                   
Line 267  class uploadATFThread(Thread): Line 270  class uploadATFThread(Thread):
             basketLen=getattr(ctx2.basketContainer,basketId).getLastVersion().numberOfItems()              basketLen=getattr(ctx2.basketContainer,basketId).getLastVersion().numberOfItems()
                           
                   
         self.result+="<html><body><h2>I got the files</h2><p>I am checking now the files</p>"          self.result+="""<html><body><h2>I got the files</h2><
                           p>I am computing the differences to the exisiting files</p>"""
                                                                         
         #start to check the files          #start to check the files
         for fn in os.listdir(dir):          for fn in os.listdir(dir):
                           
             self.result+="<p>check:%s</p>"%fn              self.result+="<p>process:%s</p>"%fn
                           
             # check if file is in the catalog              # check if file is in the catalog
             #TODO: checkCatalog is not implemented yet              #TODO: checkCatalog is not implemented yet
Line 1050  def manage_addCDLIBasketVersion(self,use Line 1054  def manage_addCDLIBasketVersion(self,use
     else:      else:
         return ob          return ob
           
 class CDLIFileObject(versionedFileObject):  class CDLIFileObject(versionedFileObject,CatalogAware):
     """CDLI file object"""      """CDLI file object"""
           
     meta_type="CDLI File Object"      meta_type="CDLI File Object"
       default_catalog='CDLIObjectsCatalog'
           
     security=ClassSecurityInfo()      security=ClassSecurityInfo()
           
Line 1220  def manage_addCDLIFile(self,id,title,loc Line 1225  def manage_addCDLIFile(self,id,title,loc
       
   
     self._setObject(id,newObj)                        self._setObject(id,newObj)                  
 #    try:  
 #        self._setObject(id,newObj)  
 #        tryToggle=False  
 #    except:  
 #      while tryToggle and (tryCount < 10):  
 #           try:  
 #                #get_transaction().commit()  
 #                self._setObject(id,newObj)  
 #                tryToggle=False  
 #            
 #           except:  
 #                time.sleep(10)  
 #                tryCount+=1  
     #no successfull adding  
     if tryToggle:  
         print "ERROR",id  
   
                   
     if RESPONSE is not None:      if RESPONSE is not None:
Line 1244  def manage_addCDLIFile(self,id,title,loc Line 1233  def manage_addCDLIFile(self,id,title,loc
   
   
   
 def splitatf(fh,dir=None):  def splitatf(fh,dir=None,ext=None):
     """split it"""      """split it"""
     ret=None      ret=None
     nf=None      nf=None
       i=0
     for line in fh.readlines():      for line in fh.readlines():
           if ext:
               i+=1
               if (i%100)==0:
                   ext.result+="."
               if i==10000:
                   i=0
                   ext.result+="<br>"
         #check if basket name is in the first line          #check if basket name is in the first line
         if line.find("#atf basket")>=0:          if line.find("#atf basket")>=0:
             ret=line.replace('#atf basket ','')              ret=line.replace('#atf basket ','')
Line 1279  class CDLIFileFolder(versionedFileFolder Line 1276  class CDLIFileFolder(versionedFileFolder
     filesMetaType=['CDLI file']      filesMetaType=['CDLI file']
     folderMetaType=['CDLI Folder']      folderMetaType=['CDLI Folder']
     default_catalog='CDLICatalog'      default_catalog='CDLICatalog'
     tmpStore=None      defaultFileCatalog=default_catalog #wenn dieses definiert ist, wird beim hinzufŸgen einer neuen version eines files dieser catalog neuiniziert
       
       tmpStore2={}
     def setTemp(self,name,value):      def setTemp(self,name,value):
         """set tmp"""          """set tmp"""
   
Line 1324  class CDLIFileFolder(versionedFileFolder Line 1323  class CDLIFileFolder(versionedFileFolder
                                                                         
   
   
     def findObjectsFromList(self,start=None,upload=None,list=None,basketName=None,numberOfObjects=None,RESPONSE=None):      def findObjectsFromList(self,display=False,start=None,upload=None,list=None,basketName=None,numberOfObjects=None,RESPONSE=None):
         """findObjectsFromList (, TAB oder LINE separated)"""          """findObjectsFromList (, TAB oder LINE separated)"""
                                                                                 
                   
Line 1361  class CDLIFileFolder(versionedFileFolder Line 1360  class CDLIFileFolder(versionedFileFolder
   
                 ret+=self.CDLICatalog({'title':fileId})                  ret+=self.CDLICatalog({'title':fileId})
             #TODO: get rid of one of these..              #TODO: get rid of one of these..
             self.REQUEST.SESSION['fileIds']=[x.getObject().getId() for x in ret]#store fieldIds in session for further usage              ids=[x.getObject().getId() for x in ret]
               self.REQUEST.SESSION['fileIds']=ids#store fieldIds in session for further usage
             self.REQUEST.SESSION['searchList']=self.REQUEST.SESSION['fileIds']              self.REQUEST.SESSION['searchList']=self.REQUEST.SESSION['fileIds']
               
               if display:
                   pt=getattr(self,'filelist.html')
                   
                   return pt(search=ids)
               else:      
             return ret              return ret
                   
           
           
         if start:          if start:
             RESPONSE.redirect("filelist.html?start:int="+str(start))              RESPONSE.redirect("filelist.html?start:int="+str(start))
                                                                                 
Line 1485  class CDLIRoot(Folder): Line 1493  class CDLIRoot(Folder):
           
     meta_type="CDLIRoot"      meta_type="CDLIRoot"
           
     def refreshTxt(self,txt=""):      def getChangesByAuthor(self,author):
           """getChangesByAuthor"""
           zcat=self.CDLICatalog
           return zcat({'lastEditor':author,
                        'sort_on':'getTime',
                        'sort_order':'descending',
                        'sort_limit':n})[:n ]
                                          
       def getLastChanges(self,n=100):
           """get the last n changes""" 
           n=int(n)                   
           zcat=self.CDLICatalog
           return zcat({'sort_on':'getLastChangeDate',
                        'sort_order':'descending',
                        'sort_limit':n})[:n ]
        
       
       def getLastChanges_html(self,n=100):
           """get the last n changes"""
           list = [x.getId for x in self.getLastChanges(n)]
           return self.cdli_main.findObjectsFromList(list=list,display=True)
                                          
       def refreshTxt(self,txt="",threadName=None):
         """txt fuer refresh"""          """txt fuer refresh"""
       
         return """ 2;url=%s?repeat=%s """%(self.absolute_url()+txt,self.threadName)          return """ 2;url=%s?repeat=%s """%(self.absolute_url()+txt,threadName)
   
           
     def getResult(self):      def getResult(self,threadName=None):
        """result of thread"""         """result of thread"""
        try:         try:
         return self._v_uploadATF.getResult()          return self._v_uploadATF[threadName].getResult()
        except:         except:
         return "One moment, please"          return "One moment, please"
           
           
       def checkThreads(self):
           """check threads"""
           return threading.enumerate()
       
     def uploadATF(self,repeat=None,upload=None,basketId=0,RESPONSE=None):      def uploadATF(self,repeat=None,upload=None,basketId=0,RESPONSE=None):
         """standard ausgabe"""          """standard ausgabe"""
         #self._v_uploadATF.returnValue=None          #self._v_uploadATF.returnValue=None
Line 1505  class CDLIRoot(Folder): Line 1540  class CDLIRoot(Folder):
         threadName=repeat          threadName=repeat
         if not threadName or threadName=="":          if not threadName or threadName=="":
             tmpVar=False              tmpVar=False
          
             thread=uploadATFThread()              thread=uploadATFThread()
             self._v_uploadATF=thread              threadName=thread.getName()[0:]                                
               if not hasattr(self,'_v_uploadATF'):
                      self._v_uploadATF={}
                                          
               self._v_uploadATF[threadName]=thread
             #self._xmltrans.start()              #self._xmltrans.start()
             #thread=Thread(target=self._v_uploadATF)              #thread=Thread(target=self._v_uploadATF)
                           
             self._v_uploadATF.set(upload,basketId,self.REQUEST['AUTHENTICATED_USER'],serverport=self.REQUEST['SERVER_PORT'])              self._v_uploadATF[threadName].set(upload,basketId,self.REQUEST['AUTHENTICATED_USER'],serverport=self.REQUEST['SERVER_PORT'])
             #thread.start()              #thread.start()
             self._v_uploadATF.start()              self._v_uploadATF[threadName].start()
   
                           
             self.threadName=self._v_uploadATF.getName()[0:]              self.threadName=self._v_uploadATF[threadName].getName()[0:]
             wait_template=self.aq_parent.ZopeFind(self.aq_parent,obj_ids=['wait_template'])              wait_template=self.aq_parent.ZopeFind(self.aq_parent,obj_ids=['wait_template'])
   
             if wait_template:              if wait_template:
                 return wait_template[0][1]()                  return wait_template[0][1]()
             pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','uploadATFWait.zpt')).__of__(self)              pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','uploadATFWait.zpt')).__of__(self)
             return pt(txt='/uploadATF')              return pt(txt='/uploadATF',threadName=threadName)
             #_v_xmltrans.run()              #_v_xmltrans.run()
                           
         else:          else:
             #recover thread, if lost              #recover thread, if lost
             if not hasattr(self,'_v_uploadATF'):              if not hasattr(self,'_v_uploadATF'):
                  self._v_uploadATF={}
               if not self._v_uploadATF.get(threadName,None):
                  for thread in threading.enumerate():                   for thread in threading.enumerate():
                          if threadName == thread.getName():                           if threadName == thread.getName():
                                        self._v_uploadATF=thread                                         self._v_uploadATF[threadName]=thread
   
             if not self._v_uploadATF.returnValue:              if not self._v_uploadATF[threadName].returnValue:
                   
   
                 wait_template=self.aq_parent.ZopeFind(self.aq_parent,obj_ids=['wait_template'])                  wait_template=self.aq_parent.ZopeFind(self.aq_parent,obj_ids=['wait_template'])
Line 1540  class CDLIRoot(Folder): Line 1582  class CDLIRoot(Folder):
                                   
                 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','uploadATFWait.zpt')).__of__(self)                  pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','uploadATFWait.zpt')).__of__(self)
   
                 return pt(txt='/uploadATF')                  return pt(txt='/uploadATF',threadName=threadName)
                                   
             else:              else:
 #                tmp={}  #                tmp={}
 #                for key in self._v_uploadATF.returnValue.keys():  #                for key in self._v_uploadATF[threadName].returnValue.keys():
 #                        t=self._v_uploadATF.returnValue[key]  #                        t=self._v_uploadATF[threadName].returnValue[key]
 #                        if type(t) is ListType:  #                        if type(t) is ListType:
 #                                       tmp[key]=self._v_uploadATF.returnValue[key][0:]  #                                       tmp[key]=self._v_uploadATF[threadName].returnValue[key][0:]
 #                        else:  #                        else:
 #                                       tmp[key]=self._v_uploadATF.returnValue[key]  #                                       tmp[key]=self._v_uploadATF[threadName].returnValue[key]
                 tmp=self.cdli_main.tmpStore  
   
                 self._v_uploadATF.continueVar=False                  tmp=self.cdli_main.tmpStore2[threadName]
                   del(self.cdli_main.tmpStore2[threadName])
                   self._v_uploadATF[threadName].continueVar=False
                 self.REQUEST.SESSION['changed']=[x[0].getId() for x in tmp['changed']]                  self.REQUEST.SESSION['changed']=[x[0].getId() for x in tmp['changed']]
                 self.REQUEST.SESSION['errors']=[x.getId() for x in tmp['errors']]                  self.REQUEST.SESSION['errors']=[x.getId() for x in tmp['errors']]
                 self.REQUEST.SESSION['newPs']=tmp['newPs']                  self.REQUEST.SESSION['newPs']=tmp['newPs']
Line 1569  class CDLIRoot(Folder): Line 1612  class CDLIRoot(Folder):
                 
         threadName=repeat          threadName=repeat
         if not threadName or threadName=="":          if not threadName or threadName=="":
               thread=uploadATFfinallyThread()
               threadName=thread.getName()[0:]
               self._v_uploadATF[threadName]=thread
                           
                         
             self._v_uploadATF=uploadATFfinallyThread()              self._v_uploadATF[threadName].set(procedure,comment=comment,basketname=basketname,unlock=unlock,SESSION=self.REQUEST.SESSION,username=self.REQUEST['AUTHENTICATED_USER'],serverport=self.REQUEST['SERVER_PORT'])
   
                   
             self._v_uploadATF.set(procedure,comment=comment,basketname=basketname,unlock=unlock,SESSION=self.REQUEST.SESSION,username=self.REQUEST['AUTHENTICATED_USER'],serverport=self.REQUEST['SERVER_PORT'])              self._v_uploadATF[threadName].start()
   
             self._v_uploadATF.start()  
   
                           
             self.threadName=self._v_uploadATF.getName()[0:]  
             wait_template=self.aq_parent.ZopeFind(self.aq_parent,obj_ids=['wait_template'])              wait_template=self.aq_parent.ZopeFind(self.aq_parent,obj_ids=['wait_template'])
   
             if wait_template:              if wait_template:
                 return wait_template[0][1]()                  return wait_template[0][1]()
             pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','uploadATFWait.zpt')).__of__(self)              pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','uploadATFWait.zpt')).__of__(self)
   
             return pt(txt='/uploadATFfinally')              return pt(txt='/uploadATFfinally',threadName=threadName)
             #_v_xmltrans.run()              #_v_xmltrans.run()
                   
         else:          else:
             #recover thread, if lost              #recover thread, if lost
             if not hasattr(self,'_v_uploadATF'):              if not hasattr(self,'_v_uploadATF'):
                  self._v_uploadATF={}
               if not self._v_uploadATF.get(threadName,None):
                  for thread in threading.enumerate():                   for thread in threading.enumerate():
                          if threadName == thread.getName():                           if threadName == thread.getName():
                                        self._v_uploadATF=thread                                         self._v_uploadATF[threadName]=thread
                                                                                 
             if hasattr(self,'_v_uploadATF') and (self._v_uploadATF is not None) and (not self._v_uploadATF.end) :              if self._v_uploadATF.get(threadName,None) and (self._v_uploadATF[threadName] is not None) and (not self._v_uploadATF[threadName].end) :
   
                 wait_template=self.aq_parent.ZopeFind(self.aq_parent,obj_ids=['wait_template'])                  wait_template=self.aq_parent.ZopeFind(self.aq_parent,obj_ids=['wait_template'])
                 if wait_template:                  if wait_template:
                         return wait_template[0][1]()                          return wait_template[0][1]()
                                   
                 pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','uploadATFWait.zpt')).__of__(self)                  pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','uploadATFWait.zpt')).__of__(self)
                 return pt(txt='/uploadATFfinally')                  return pt(txt='/uploadATFfinally',threadName=threadName)
             else:              else:
   
               if RESPONSE is not None:                if RESPONSE is not None:

Removed from v.1.22  
changed lines
  Added in v.1.25


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