Ignore:
Timestamp:
16.11.2009 15:50:56 (3 years ago)
Author:
cmeier
Message:

zms-2.12.1-01

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ZMS/trunk/_confmanager.py

    r792 r794  
    3737import urllib 
    3838# Product imports. 
    39 import IZMSMetamodelProvider, IZMSFormatProvider 
     39import IZMSMetamodelProvider, IZMSFormatProvider, IZMSSvnInterface 
    4040import _globals 
    4141import _fileutil 
     
    133133    implements( 
    134134      IZMSMetamodelProvider.IZMSMetamodelProvider, 
    135       IZMSFormatProvider.IZMSFormatProvider) 
     135      IZMSFormatProvider.IZMSFormatProvider, 
     136      IZMSSvnInterface.IZMSSvnInterface) 
    136137 
    137138    # Management Interface. 
     
    274275    #  ConfManager.svnCopy: 
    275276    # -------------------------------------------------------------------------- 
    276     def svnCopy(self, node, path, ids=[]): 
     277    def svnCopy(self, node, path, ids=[], excl_ids=[]): 
    277278      l = [] 
    278       for ob in node.objectValues(): 
    279         action = None 
    280         id = absattr(ob.id) 
    281         filepath = path+os.sep+id 
    282         filemtime = None 
    283         mtime = long(ob.bobobase_modification_time().timeTime()) 
    284         meta_type = ob.meta_type 
    285         if ob.meta_type in ['DTML Method','DTML Document','File','Image','Script (Python)']: 
    286           if ob.meta_type in ['DTML Method','DTML Document']: 
    287             filepath += '.dtml' 
    288           if ob.meta_type in ['Script (Python)']: 
    289             filepath += '.py' 
    290           if os.path.exists( filepath): 
    291             filestat = os.stat(filepath) 
    292             filemtime = long(filestat[stat.ST_MTIME]) 
    293             if mtime > filemtime: 
    294               action = 'update' 
    295           else:  
    296             action = 'insert' 
    297           if action: 
    298             l.append({'action':action,'filepath':filepath,'mtime':mtime,'filemtime':filemtime,'meta_type':meta_type}) 
    299             if filepath in ids: 
    300               _fileutil.exportObj(ob,filepath) 
    301               atime = mtime 
    302               times = (atime,mtime) 
    303               os.utime(filepath,times) 
    304         elif ob.meta_type in ['Folder','ZMS','ZMSMetamodelProvider']: 
    305           l.extend( self.svnCopy(ob,filepath,ids)) 
     279      for ob in node.objectValues(['ZMS']): 
     280        # Add content-object artefacts to exclude-ids. 
     281        for metaObjId in ob.getMetaobjIds(): 
     282          for metaObjAttrId in ob.getMetaobjAttrIds( metaObjId): 
     283            metaObjAttr = ob.getMetaobjAttr(metaObjId,metaObjAttrId) 
     284            if metaObjAttr['type'] in ob.metaobj_manager.valid_zopetypes: 
     285              excl_ids.append( metaObjAttrId) 
     286      obs = map( lambda x: (absattr(x.id), x), node.objectValues()) 
     287      obs.sort() 
     288      for x in obs: 
     289        id = x[0] 
     290        ob = x[1] 
     291        if id not in excl_ids and not id.startswith('A_'): 
     292          action = None 
     293          filepath = path+'/'+id 
     294          filemtime = None 
     295          mtime = long(ob.bobobase_modification_time().timeTime()) 
     296          meta_type = ob.meta_type 
     297          if node.meta_type == 'Folder' and ob.meta_type in ['DTML Method','DTML Document','File','Image','Script (Python)']: 
     298            if ob.meta_type in ['DTML Method','DTML Document']: 
     299              filepath += '.dtml' 
     300            if ob.meta_type in ['Script (Python)']: 
     301              filepath += '.py' 
     302            if os.path.exists( filepath): 
     303              filestat = os.stat(filepath) 
     304              filemtime = long(filestat[stat.ST_MTIME]) 
     305              if mtime > filemtime: 
     306                action = 'refresh' 
     307              elif mtime < filemtime: 
     308                action = 'conflict' 
     309            else:  
     310              action = 'add' 
     311            if action: 
     312              l.append({'action':action,'filepath':filepath,'mtime':mtime,'filemtime':filemtime,'meta_type':meta_type}) 
     313              if filepath in ids: 
     314                _fileutil.exportObj(ob,filepath) 
     315                atime = mtime 
     316                times = (atime,mtime) 
     317                os.utime(filepath,times) 
     318          elif ob.meta_type == 'ZMS': 
     319            l.extend( ob.metaobj_manager.svnCopy( node, path, ids)) 
     320          elif ob.meta_type == 'Folder': 
     321            if not os.path.exists( filepath): 
     322              action = 'add' 
     323              l.append({'action':action,'filepath':filepath,'meta_type':meta_type}) 
     324              if filepath in ids: 
     325                _fileutil.mkDir(filepath) 
     326            l.extend( self.svnCopy(ob,filepath,ids)) 
    306327      return l 
    307328 
     
    310331    #  ConfManager.svnUpdate: 
    311332    # -------------------------------------------------------------------------- 
    312     def svnUpdate(self, node, path, ids=[]): 
     333    def svnUpdate(self, node, path, ids=[], excl_ids=[]): 
    313334      l = [] 
    314335      path_ids = [] 
     
    316337        action = None 
    317338        id = filename 
    318         filepath = path+os.sep+id 
     339        filepath = path+'/'+id 
    319340        filestat = os.stat(filepath) 
    320341        mode = filestat[stat.ST_MODE] 
     
    327348        ob = getattr( node, id, None) 
    328349        if stat.S_ISDIR(mode): 
    329           if filename != '.svn': 
     350          if filename == 'metaobj_manager': 
     351            for ob in node.objectValues(['ZMS']): 
     352              l.extend( ob.metaobj_manager.svnUpdate( node, filepath, ids)) 
     353          elif filename != '.svn': 
    330354            if ob is None: 
    331355              if filepath in ids: 
     
    334358              meta_type = 'Folder' 
    335359              mtime = 0 
    336               action = 'insert' 
     360              action = 'add' 
    337361            if action: 
    338362              l.append({'action':action,'filepath':filepath,'mtime':mtime,'filemtime':filemtime,'meta_type':meta_type}) 
     
    360384            ob = getattr( node, id, None) 
    361385            mtime = 0 
    362             action = 'insert' 
     386            action = 'add' 
    363387          else: 
    364388            meta_type = ob.meta_type 
     
    374398              ob.manage_upload(data) 
    375399              file.close() 
    376       if node is not None: 
    377         for id in filter( lambda x: x not in path_ids, node.objectIds(['DTML Method','File','Folder','Image'])): 
     400      if node is not None and node.meta_type != 'ZMS': 
     401        for ob in node.objectValues(['ZMS']): 
     402          # Add content-object artefacts to exclude-ids. 
     403          for metaObjId in ob.getMetaobjIds(): 
     404            for metaObjAttrId in ob.getMetaobjAttrIds( metaObjId): 
     405              metaObjAttr = ob.getMetaobjAttr(metaObjId,metaObjAttrId) 
     406              if metaObjAttr['type'] in ob.metaobj_manager.valid_zopetypes: 
     407                excl_ids.append( metaObjAttrId) 
     408        for id in filter( lambda x: x not in path_ids and x not in excl_ids and not x.startswith('A_'), node.objectIds(['DTML Method','File','Folder','Image'])): 
    378409          ob = getattr( node, id) 
    379410          action = 'delete' 
    380           filepath = path+os.sep+id 
     411          filepath = path+'/'+id 
    381412          mtime = long(ob.bobobase_modification_time().timeTime()) 
    382413          filemtime = 0 
     
    758789        home_id = home.id 
    759790        temp_folder = self.temp_folder 
     791        # Init exclude-ids. 
    760792        excl_ids = [] 
     793        # Add clients-folders to exclude-ids. 
    761794        for folder in home.objectValues( ['Folder']): 
    762795          if len( folder.objectValues( ['ZMS'])) > 0: 
    763796            excl_ids.append( absattr( folder.id)) 
     797        # Add content-object artefacts to exclude-ids. 
    764798        for metaObjId in self.getMetaobjIds(): 
    765799          for metaObjAttrId in self.getMetaobjAttrIds( metaObjId): 
     
    767801            if metaObjAttr['type'] in self.metaobj_manager.valid_zopetypes: 
    768802              excl_ids.append( metaObjAttrId) 
    769         ids = filter( lambda x: x not in excl_ids, home.objectIds(['DTML Document','DTML Method','Folder','Script (Python)'])) 
     803        # Filter ids. 
     804        ids = filter( lambda x: x not in excl_ids, home.objectIds(self.metaobj_manager.valid_zopetypes)) 
    770805        if btn == self.getZMILangStr('BTN_EXPORT'): 
    771806          if home_id in temp_folder.objectIds(): 
Note: See TracChangeset for help on using the changeset viewer.