Ignore:
Timestamp:
03/03/09 19:51:40 (15 years ago)
Author:
nanardon
Message:
  • add create object to UNIX base
File:
1 edited

Legend:

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

    r7 r16  
    9191} 
    9292 
     93=head2 create_object($type, $id, %data) 
     94 
     95Create and return an object of type $type with unique id 
     96$id having %data. 
     97 
     98This method should be provided by the data base handler. 
     99 
     100=cut 
     101 
     102sub create_object { 
     103    my ($self, $otype, $id, %data) = @_; 
     104    return; 
     105} 
     106 
     107=head2 create_c_object($type, $id, %data) 
     108 
     109Create and return an object of type $type with unique id 
     110$id having %data using canonical fields 
     111 
     112=cut 
     113 
     114sub create_c_object { 
     115    my ($self, $otype, $id, %cdata) = @_; 
     116 
     117    my %data; 
     118    foreach my $cfield (keys %cdata) { 
     119        my $field = $self->base->get_field_name($self->type, $cfield) or next; 
     120        $data{$field} = $cdata{$cfield}; 
     121    } 
     122    keys %data or return 1; # TODO: return an error ? 
     123    $self->create_object($otype, $id, %data); 
     124} 
     125 
    93126=head2 load 
    94127 
Note: See TracChangeset for help on using the changeset viewer.