Changeset 944 for LATMOS-Accounts


Ignore:
Timestamp:
04/26/12 18:54:04 (12 years ago)
Author:
nanardon
Message:

Fix attributes registration when attributes has description in perl code

Location:
LATMOS-Accounts/lib/LATMOS/Accounts/Bases
Files:
2 edited

Legend:

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

    r943 r944  
    321321} 
    322322 
     323sub is_registered_attribute { 
     324    my ($self, $otype, $attribute) = @_; 
     325    my $pclass = $self->_load_obj_class($otype) or return; 
     326    $pclass->is_registered_attribute($self, $attribute); 
     327} 
     328 
    323329sub get_attribute_comment { 
    324330    my ($self, $otype, $attribute) = @_; 
  • LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/objects.pm

    r861 r944  
    619619    my ($class, $base, $attribute, $comment) = @_; 
    620620 
    621     $base->attribute($class->type, $attribute) and do { 
     621    $class->is_registered_attribute($base, $attribute) and do { 
    622622        $base->log(LA_ERR, "The attribute $attribute already exists"); 
    623623        return; 
     
    630630    ); 
    631631    my $res = $sth->execute($attribute, $comment); 
     632} 
     633 
     634sub is_registered_attribute { 
     635    my ($class, $base, $attribute) = @_; 
     636 
     637    my $sth = $base->db->prepare( 
     638        sprintf(q{ 
     639            select 1 from %s where canonical = ? 
     640            }, $class->attributes_table 
     641        ) 
     642    ); 
     643    $sth->execute($attribute); 
     644    my $res = $sth->fetchrow_hashref; 
     645    return $res ? 1 : 0; 
    632646} 
    633647 
Note: See TracChangeset for help on using the changeset viewer.