Ignore:
Timestamp:
05/10/09 19:03:39 (15 years ago)
Author:
nanardon
Message:
  • allow to sync specific object
File:
1 edited

Legend:

Unmodified
Added
Removed
  • LATMOS-Accounts/lib/LATMOS/Accounts/Synchro.pm

    r77 r83  
    140140            foreach my $uid (@lobjfrom) { 
    141141                my $sobj = $self->from->get_object($otype, $uid); 
    142                 if ($exists{$uid}) { 
    143                     my %fields = map { $_ => $sobj->get_c_field($_, 'r') } @common_fields; 
    144                     my $dobj = $destbase->get_object($otype, $uid); 
    145                     $dobj->set_c_fields(%fields) unless($self->{options}{test}); 
    146                     warn "  $otype $uid: synched\n"; 
    147                 } elsif (!$self->{options}{nocreate} && !$options{nocreate}) { 
    148                     my %fields = map { $_ => $sobj->get_c_field($_, 'r') } @common_fields; 
    149                     $destbase->create_c_object($otype, $uid, %fields) unless($self->{options}{test}); 
    150                     warn "  $otype $uid: created\n"; 
    151                 } 
     142                $destbase->sync_object( 
     143                    $sobj, 
     144                    nocreate => ($self->{options}{nocreate} || $options{nocreate}), 
     145                ) unless($self->{options}{test}); 
     146                warn "  $otype $uid: synched\n"; 
    152147            } 
    153148        } 
     
    172167} 
    173168 
     169sub sync_object { 
     170    my ($self, $otype, $uid) = @_; 
     171    my $sobj = $self->from->get_object($otype, $uid) or return; 
     172    foreach ($self->to) { 
     173        $_->sync_object($sobj) 
     174    } 
     175    foreach ($self->to) { 
     176        $_->commit; 
     177    } 
     178    1; 
     179} 
     180 
    174181sub process { 
    175182    my ($self) = @_; 
Note: See TracChangeset for help on using the changeset viewer.