Changeset 794 for ZMS/trunk/_confmanager.py
- Timestamp:
- 16.11.2009 15:50:56 (3 years ago)
- File:
-
- 1 edited
-
ZMS/trunk/_confmanager.py (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ZMS/trunk/_confmanager.py
r792 r794 37 37 import urllib 38 38 # Product imports. 39 import IZMSMetamodelProvider, IZMSFormatProvider 39 import IZMSMetamodelProvider, IZMSFormatProvider, IZMSSvnInterface 40 40 import _globals 41 41 import _fileutil … … 133 133 implements( 134 134 IZMSMetamodelProvider.IZMSMetamodelProvider, 135 IZMSFormatProvider.IZMSFormatProvider) 135 IZMSFormatProvider.IZMSFormatProvider, 136 IZMSSvnInterface.IZMSSvnInterface) 136 137 137 138 # Management Interface. … … 274 275 # ConfManager.svnCopy: 275 276 # -------------------------------------------------------------------------- 276 def svnCopy(self, node, path, ids=[] ):277 def svnCopy(self, node, path, ids=[], excl_ids=[]): 277 278 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)) 306 327 return l 307 328 … … 310 331 # ConfManager.svnUpdate: 311 332 # -------------------------------------------------------------------------- 312 def svnUpdate(self, node, path, ids=[] ):333 def svnUpdate(self, node, path, ids=[], excl_ids=[]): 313 334 l = [] 314 335 path_ids = [] … … 316 337 action = None 317 338 id = filename 318 filepath = path+ os.sep+id339 filepath = path+'/'+id 319 340 filestat = os.stat(filepath) 320 341 mode = filestat[stat.ST_MODE] … … 327 348 ob = getattr( node, id, None) 328 349 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': 330 354 if ob is None: 331 355 if filepath in ids: … … 334 358 meta_type = 'Folder' 335 359 mtime = 0 336 action = ' insert'360 action = 'add' 337 361 if action: 338 362 l.append({'action':action,'filepath':filepath,'mtime':mtime,'filemtime':filemtime,'meta_type':meta_type}) … … 360 384 ob = getattr( node, id, None) 361 385 mtime = 0 362 action = ' insert'386 action = 'add' 363 387 else: 364 388 meta_type = ob.meta_type … … 374 398 ob.manage_upload(data) 375 399 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'])): 378 409 ob = getattr( node, id) 379 410 action = 'delete' 380 filepath = path+ os.sep+id411 filepath = path+'/'+id 381 412 mtime = long(ob.bobobase_modification_time().timeTime()) 382 413 filemtime = 0 … … 758 789 home_id = home.id 759 790 temp_folder = self.temp_folder 791 # Init exclude-ids. 760 792 excl_ids = [] 793 # Add clients-folders to exclude-ids. 761 794 for folder in home.objectValues( ['Folder']): 762 795 if len( folder.objectValues( ['ZMS'])) > 0: 763 796 excl_ids.append( absattr( folder.id)) 797 # Add content-object artefacts to exclude-ids. 764 798 for metaObjId in self.getMetaobjIds(): 765 799 for metaObjAttrId in self.getMetaobjAttrIds( metaObjId): … … 767 801 if metaObjAttr['type'] in self.metaobj_manager.valid_zopetypes: 768 802 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)) 770 805 if btn == self.getZMILangStr('BTN_EXPORT'): 771 806 if home_id in temp_folder.objectIds():
Note: See TracChangeset
for help on using the changeset viewer.
