Ignore:
Timestamp:
10/07/12 14:41:56 (7 years ago)
Author:
mnagni
Message:

Corrected an error in the generation of the classes "synchronize" method.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mauRepo/CedaMolesModel/trunk/ceda_moles_model/ascore/utils.py

    r8442 r8457  
    4343    return toHash 
    4444 
     45def _synchAttributes(instance, done = []): 
     46    """ 
     47        Restores the class's composition elements. 
     48        This methods should be called before any commit operation 
     49        @param instance: the instance that has to be restored  
     50        @param done: the instance that has to be restored         
     51    """     
     52    if instance in done: 
     53        return 
     54    if hasattr(instance, 'synchronize'): 
     55        instance.synchronize() 
     56        done.append(instance) 
     57    for attr in dir(instance): 
     58        if attr != '__class__' and attr.startswith('_') \ 
     59            and not attr.startswith('__') and hasattr(getattr(instance,attr), 'synchronize'): 
     60                _synchAttributes(getattr(instance,attr), done) 
     61 
    4562def synchAttributes(instance): 
    4663    """ 
    4764        Restores the class's composition elements. 
    4865        This methods should be called before any commit operation 
    49         @param instance: the instance that has to be restored  
     66        @param instance: the instance that has to be restored          
    5067    """ 
    51     if hasattr(instance, 'synchronize'): 
    52         instance.synchronize() 
    53     for attr in dir(instance): 
    54         try: 
    55             if attr != '__class__' and attr.startswith('_') \ 
    56                 and not attr.startswith('__') and hasattr(getattr(instance,attr), 'synchronize'): 
    57                 synchAttributes(getattr(instance,attr)) 
    58         except Exception as e: 
    59             pass 
     68    _synchAttributes(instance,[]) 
Note: See TracChangeset for help on using the changeset viewer.