Ignore:
Timestamp:
05/22/12 00:15:11 (12 years ago)
Author:
nanardon
Message:
  • fix/complete/improve documentation
Location:
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql
Files:
12 edited

Legend:

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

    r971 r1014  
    2727sub _yaml_attr { qw(description notifyMail) } 
    2828 
    29 sub object_table { 'accreq' } 
     29sub _object_table { 'accreq' } 
    3030 
    31 sub key_field { 'name' } 
     31sub _key_field { 'name' } 
    3232 
    33 sub has_extended_attributes { 1 } 
     33sub _has_extended_attributes { 1 } 
    3434 
    3535sub _get_attr_schema { 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Address.pm

    r943 r1014  
    3737=cut 
    3838 
    39 sub object_table { 'address' } 
     39sub _object_table { 'address' } 
    4040 
    41 sub key_field { 'name' } 
     41sub _key_field { 'name' } 
    4242 
    43 sub has_extended_attributes { 1 } 
     43sub _has_extended_attributes { 1 } 
    4444 
    4545sub _get_attr_schema { 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Aliases.pm

    r959 r1014  
    3838=cut 
    3939 
    40 sub object_table { 'aliases' } 
     40sub _object_table { 'aliases' } 
    4141 
    42 sub key_field { 'name' } 
     42sub _key_field { 'name' } 
    4343 
    44 sub has_extended_attributes { 1 } 
     44sub _has_extended_attributes { 1 } 
    4545 
    4646sub _get_attr_schema { 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Group.pm

    r861 r1014  
    3838=cut 
    3939 
    40 sub object_table { 'group' } 
     40sub _object_table { 'group' } 
    4141 
    42 sub key_field { 'name' } 
     42sub _key_field { 'name' } 
    4343 
    44 sub has_extended_attributes { 1 } 
     44sub _has_extended_attributes { 1 } 
    4545 
    4646sub _get_attr_schema { 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Nethost.pm

    r920 r1014  
    3838=cut 
    3939 
    40 sub object_table { 'nethost' } 
    41  
    42 sub key_field { 'name' } 
    43  
    44 sub has_extended_attributes { 1 } 
     40sub _object_table { 'nethost' } 
     41 
     42sub _key_field { 'name' } 
     43 
     44sub _has_extended_attributes { 1 } 
    4545 
    4646sub _get_attr_schema { 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Netzone.pm

    r922 r1014  
    3737=cut 
    3838 
    39 sub object_table { 'netzone' } 
    40  
    41 sub key_field { 'name' } 
    42  
    43 sub has_extended_attributes { 1 } 
     39sub _object_table { 'netzone' } 
     40 
     41sub _key_field { 'name' } 
     42 
     43sub _has_extended_attributes { 1 } 
    4444 
    4545sub _get_attr_schema { 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Onlyaddress.pm

    r830 r1014  
    1818              order by %s.%s 
    1919            }, 
    20             $base->db->quote_identifier($class->object_table), 
    21             $base->db->quote_identifier($class->key_field), 
    22             $base->db->quote_identifier($class->object_table), 
    23             $base->db->quote_identifier($class->object_table), 
     20            $base->db->quote_identifier($class->_object_table), 
     21            $base->db->quote_identifier($class->_key_field), 
     22            $base->db->quote_identifier($class->_object_table), 
     23            $base->db->quote_identifier($class->_object_table), 
    2424            ($base->{wexported} ? '' : 'and "user".exported = true'), 
    25             $base->db->quote_identifier($class->object_table), 
    26             $base->db->quote_identifier($class->object_table. '_attributes'), # attr 
     25            $base->db->quote_identifier($class->_object_table), 
     26            $base->db->quote_identifier($class->_object_table. '_attributes'), # attr 
    2727            ($base->{wexported} ? '' : 'and ' . 
    28                 $base->db->quote_identifier($class->object_table) . '.exported = true'), 
    29             $base->db->quote_identifier($class->object_table), 
    30             $base->db->quote_identifier($class->key_field), 
     28                $base->db->quote_identifier($class->_object_table) . '.exported = true'), 
     29            $base->db->quote_identifier($class->_object_table), 
     30            $base->db->quote_identifier($class->_key_field), 
    3131        ) 
    3232    ); 
     
    4646            q{select %s as k from %s where ikey not in (select okey from %s 
    4747            where attr = 'isMainAddress') and rev > ? %s order by %s}, 
    48             $base->db->quote_identifier($class->key_field), 
    49             $base->db->quote_identifier($class->object_table), 
    50             $base->db->quote_identifier($class->object_table. '_attributes'), # attr 
     48            $base->db->quote_identifier($class->_key_field), 
     49            $base->db->quote_identifier($class->_object_table), 
     50            $base->db->quote_identifier($class->_object_table. '_attributes'), # attr 
    5151            ($base->{wexported} ? '' : 'and exported = true'), 
    52             $base->db->quote_identifier($class->key_field), 
     52            $base->db->quote_identifier($class->_key_field), 
    5353        ) 
    5454    ); 
     
    6565    my $sth = $base->db->prepare_cached( 
    6666        sprintf(q{select 1 from %s where %s = ? %s and ikey not in (select okey from %s where attr = 'isMainAddress')}, 
    67             $base->db->quote_identifier($class->object_table), 
    68             $base->db->quote_identifier($class->key_field), 
     67            $base->db->quote_identifier($class->_object_table), 
     68            $base->db->quote_identifier($class->_key_field), 
    6969            ($base->{wexported} ? '' : 'and exported = true'), 
    70             $base->db->quote_identifier($class->object_table. '_attributes'), 
     70            $base->db->quote_identifier($class->_object_table. '_attributes'), 
    7171        ), 
    7272    ); 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Revaliases.pm

    r916 r1014  
    3838=cut 
    3939 
    40 sub object_table { 'revaliases' } 
     40sub _object_table { 'revaliases' } 
    4141 
    42 sub key_field { 'name' } 
     42sub _key_field { 'name' } 
    4343 
    44 sub has_extended_attributes { 0 } 
     44sub _has_extended_attributes { 0 } 
    4545 
    4646sub _get_attr_schema { 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Site.pm

    r861 r1014  
    3737=cut 
    3838 
    39 sub object_table { 'site' } 
     39sub _object_table { 'site' } 
    4040 
    41 sub key_field { 'name' } 
     41sub _key_field { 'name' } 
    4242 
    43 sub has_extended_attributes { 1 } 
     43sub _has_extended_attributes { 1 } 
    4444 
    4545sub _get_attr_schema { 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Sutype.pm

    r861 r1014  
    3737=cut 
    3838 
    39 sub object_table { 'su_type' } 
     39sub _object_table { 'su_type' } 
    4040 
    41 sub key_field { 'name' } 
     41sub _key_field { 'name' } 
    4242 
    43 sub has_extended_attributes { 0 } 
     43sub _has_extended_attributes { 0 } 
    4444 
    45451; 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/User.pm

    r959 r1014  
    3333=cut 
    3434 
    35 sub object_table { 'user' } 
    36  
    37 sub key_field { 'name' } 
    38  
    39 sub has_extended_attributes { 1 } 
     35sub _object_table { 'user' } 
     36 
     37sub _key_field { 'name' } 
     38 
     39sub _has_extended_attributes { 1 } 
    4040 
    4141sub _get_attr_schema { 
     
    206206                            q{select extract(epoch from expire) + 11644474161 as expire 
    207207                            from %s where %s = ?}, 
    208                             $obj->db->quote_identifier($obj->object_table), 
    209                             $obj->db->quote_identifier($obj->key_field), 
     208                            $obj->db->quote_identifier($obj->_object_table), 
     209                            $obj->db->quote_identifier($obj->_key_field), 
    210210                        ) 
    211211                    ); 
     
    226226                            q{select justify_hours(expire - '1/1/1970'::timestamp) as expire 
    227227                            from %s where %s = ?}, 
    228                             $obj->db->quote_identifier($obj->object_table), 
    229                             $obj->db->quote_identifier($obj->key_field), 
     228                            $obj->db->quote_identifier($obj->_object_table), 
     229                            $obj->db->quote_identifier($obj->_key_field), 
    230230                        ) 
    231231                    ); 
     
    293293                            q{select to_char(expire, 'YYYY/MM/DD') as expire 
    294294                            from %s where %s = ?}, 
    295                             $obj->db->quote_identifier($obj->object_table), 
    296                             $obj->db->quote_identifier($obj->key_field), 
     295                            $obj->db->quote_identifier($obj->_object_table), 
     296                            $obj->db->quote_identifier($obj->_key_field), 
    297297                        ) 
    298298                    ); 
     
    329329                                q{select to_char(expire AT TIME ZONE 'Z', 'YYYYMMDDHH24MISSZ') as expire 
    330330                                from %s where %s = ? and expire < now()}, 
    331                                 $obj->db->quote_identifier($obj->object_table), 
    332                                 $obj->db->quote_identifier($obj->key_field), 
     331                                $obj->db->quote_identifier($obj->_object_table), 
     332                                $obj->db->quote_identifier($obj->_key_field), 
    333333                            ) 
    334334                        ); 
     
    354354                q{select date_part('epoch', expire)::int as expire 
    355355                from %s where %s = ?}, 
    356                 $self->db->quote_identifier($self->object_table), 
    357                 $self->db->quote_identifier($self->key_field), 
     356                $self->db->quote_identifier($self->_object_table), 
     357                $self->db->quote_identifier($self->_key_field), 
    358358            ) 
    359359        ); 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/objects.pm

    r944 r1014  
    4242=cut 
    4343 
    44 sub attributes_table { $_[0]->object_table . '_attributes_list' } 
     44sub _attributes_table { $_[0]->_object_table . '_attributes_list' } 
    4545 
    4646sub list { 
     
    5050        sprintf( 
    5151            q{select %s as k from %s %s order by %s}, 
    52             $base->db->quote_identifier($class->key_field), 
    53             $base->db->quote_identifier($class->object_table), 
     52            $base->db->quote_identifier($class->_key_field), 
     53            $base->db->quote_identifier($class->_object_table), 
    5454            ($base->{wexported} ? '' : 'where exported = true'), 
    55             $base->db->quote_identifier($class->key_field), 
     55            $base->db->quote_identifier($class->_key_field), 
    5656        ) 
    5757    ); 
     
    6969        sprintf( 
    7070            q{select %s as k from %s where rev > ? %s order by %s}, 
    71             $base->db->quote_identifier($class->key_field), 
    72             $base->db->quote_identifier($class->object_table), 
     71            $base->db->quote_identifier($class->_key_field), 
     72            $base->db->quote_identifier($class->_object_table), 
    7373            ($base->{wexported} ? '' : 'and exported = true'), 
    74             $base->db->quote_identifier($class->key_field), 
     74            $base->db->quote_identifier($class->_key_field), 
    7575        ) 
    7676    ); 
     
    8383} 
    8484 
    85 sub has_extended_attributes { 0 } 
     85sub _has_extended_attributes { 0 } 
    8686 
    8787sub _get_attr_schema { 
    8888    my ($class, $base, $info) = @_; 
    8989    $info ||= {}; 
    90     if (!$base->{__cache}{$class->object_table}{inline}) { 
    91         $base->{__cache}{$class->object_table}{inline} = []; 
     90    if (!$base->{__cache}{$class->_object_table}{inline}) { 
     91        $base->{__cache}{$class->_object_table}{inline} = []; 
    9292        my $sth = $base->db->prepare( 
    9393            q{SELECT column_name FROM information_schema.columns 
    9494              WHERE table_name = ?} 
    9595        ); 
    96         $sth->execute($class->object_table); 
     96        $sth->execute($class->_object_table); 
    9797        while (my $res = $sth->fetchrow_hashref) { 
    98             push(@{$base->{__cache}{$class->object_table}{inline}}, 
     98            push(@{$base->{__cache}{$class->_object_table}{inline}}, 
    9999                $res->{column_name}); 
    100100        } 
    101101    } 
    102     foreach (@{$base->{__cache}{$class->object_table}{inline}}) { 
     102    foreach (@{$base->{__cache}{$class->_object_table}{inline}}) { 
    103103        $info->{$_}{inline} = 1; 
    104104        if (m/^(rev|date|create|ikey)$/) { 
     
    106106        } 
    107107    } 
    108     if ($class->has_extended_attributes) { 
    109         if (!$base->{__cache}{$class->object_table}{extend}) { 
    110             $base->{__cache}{$class->object_table}{extend} = []; 
     108    if ($class->_has_extended_attributes) { 
     109        if (!$base->{__cache}{$class->_object_table}{extend}) { 
     110            $base->{__cache}{$class->_object_table}{extend} = []; 
    111111            my $sth = $base->db->prepare_cached( 
    112112                sprintf( 
    113113                    q{select canonical from %s order by canonical}, 
    114                     $base->db->quote_identifier($class->attributes_table), 
     114                    $base->db->quote_identifier($class->_attributes_table), 
    115115                ) 
    116116            ); 
    117117            $sth->execute; 
    118118            while (my $res = $sth->fetchrow_hashref) { 
    119                 push(@{$base->{__cache}{$class->object_table}{extend}}, 
     119                push(@{$base->{__cache}{$class->_object_table}{extend}}, 
    120120                        $res->{canonical}); 
    121121            } 
    122122        } 
    123         foreach (@{$base->{__cache}{$class->object_table}{extend}}) { 
     123        foreach (@{$base->{__cache}{$class->_object_table}{extend}}) { 
    124124            $info->{$_} ||= {}; 
    125125        } 
     
    142142    my $sth = $base->db->prepare_cached( 
    143143        sprintf(q{select 1 from %s where %s = ? %s}, 
    144             $base->db->quote_identifier($class->object_table), 
    145             $base->db->quote_identifier($class->key_field), 
     144            $base->db->quote_identifier($class->_object_table), 
     145            $base->db->quote_identifier($class->_key_field), 
    146146            ($base->{wexported} ? '' : 'and exported = true'), 
    147147        ), 
     
    160160        sprintf( 
    161161            q{select ikey from %s where %s = ?}, 
    162             $base->db->quote_identifier($class->object_table), 
    163             $base->db->quote_identifier($class->key_field), 
     162            $base->db->quote_identifier($class->_object_table), 
     163            $base->db->quote_identifier($class->_key_field), 
    164164        ) 
    165165    ); 
     
    190190        } 
    191191    } 
    192     $first{$class->key_field} = $id; 
     192    $first{$class->_key_field} = $id; 
    193193 
    194194    my $sth = $base->db->prepare( 
    195195        sprintf( 
    196196            q{insert into %s (%s) values (%s)}, 
    197             $base->db->quote_identifier($class->object_table), 
     197            $base->db->quote_identifier($class->_object_table), 
    198198            join(', ', map { $base->db->quote_identifier($_) } sort keys %first), 
    199199            join(',', qw(?) x scalar(keys %first)), 
     
    213213        sprintf( 
    214214            q{delete from %s where %s = ?}, 
    215             $base->db->quote_identifier($class->object_table), 
    216             $base->db->quote_identifier($class->key_field), 
     215            $base->db->quote_identifier($class->_object_table), 
     216            $base->db->quote_identifier($class->_key_field), 
    217217        ) 
    218218    ); 
     
    226226        sprintf( 
    227227            q{update %s set %s = ? where %s = ?}, 
    228             $base->db->quote_identifier($class->object_table), 
    229             $base->db->quote_identifier($class->key_field), 
    230             $base->db->quote_identifier($class->key_field), 
     228            $base->db->quote_identifier($class->_object_table), 
     229            $base->db->quote_identifier($class->_key_field), 
     230            $base->db->quote_identifier($class->_key_field), 
    231231        ) 
    232232    ); 
     
    246246} 
    247247 
    248 sub quote_object_table { 
     248sub quote__object_table { 
    249249    my ($self) = @_; 
    250     my $table = $self->object_table or return; 
     250    my $table = $self->_object_table or return; 
    251251    $self->db->quote_identifier($table); 
    252252} 
    253 sub quote_key_field {  
     253sub quote__key_field {  
    254254    my ($self) = @_; 
    255     my $key_field = $self->key_field or return; 
    256     $self->db->quote_identifier($key_field); 
     255    my $_key_field = $self->key_field or return; 
     256    $self->db->quote_identifier($_key_field); 
    257257} 
    258258 
     
    268268            q{select %s from %s where %s = ?}, 
    269269            $self->db->quote_identifier(lc($field)), 
    270             $self->quote_object_table, 
    271             $self->quote_key_field, 
     270            $self->quote__object_table, 
     271            $self->quote__key_field, 
    272272        ) 
    273273    ); 
     
    276276    $sth->finish; 
    277277    return $res->{$field}; 
    278     } elsif ($self->has_extended_attributes) { # else, then we mandatory have extend attr 
     278    } elsif ($self->_has_extended_attributes) { # else, then we mandatory have extend attr 
    279279        $self->base->{__cache}{"_" . $self->type} ||= {}; 
    280280        my $__cache = $self->base->{__cache}{"_" . $self->type}; 
     
    288288                where %s = ? 
    289289                }, 
    290                 $self->db->quote_identifier($self->object_table. '_attributes'), 
    291                 $self->db->quote_identifier($self->object_table), 
    292                 $self->db->quote_identifier($self->key_field), 
     290                $self->db->quote_identifier($self->_object_table. '_attributes'), 
     291                $self->db->quote_identifier($self->_object_table), 
     292                $self->db->quote_identifier($self->_key_field), 
    293293            ) 
    294294        ); 
     
    332332            sprintf( 
    333333                q{update %s set %s where %s = ?}, 
    334                 $self->quote_object_table, 
     334                $self->quote__object_table, 
    335335                join(', ', @fields), 
    336                 $self->quote_key_field, 
     336                $self->quote__key_field, 
    337337            ) 
    338338        ); 
     
    348348    } 
    349349     
    350     if ($self->has_extended_attributes) { 
     350    if ($self->_has_extended_attributes) { 
    351351        my $sthd = $self->db->prepare_cached( 
    352352            sprintf( 
    353353                q{delete from %s where okey = ? and attr = ?}, 
    354                 $self->db->quote_identifier($self->object_table. '_attributes'), 
     354                $self->db->quote_identifier($self->_object_table. '_attributes'), 
    355355            ), 
    356356        ); 
     
    358358            sprintf( 
    359359                q{delete from %s where okey = ? and attr = ? and value = ?}, 
    360                 $self->db->quote_identifier($self->object_table. '_attributes'), 
     360                $self->db->quote_identifier($self->_object_table. '_attributes'), 
    361361            ), 
    362362        ); 
     
    364364            sprintf( 
    365365                q{insert into %s (okey, attr, value) values (?,?,?)}, 
    366                 $self->db->quote_identifier($self->object_table. '_attributes'), 
     366                $self->db->quote_identifier($self->_object_table. '_attributes'), 
    367367            ) 
    368368        ); 
     
    370370            sprintf( 
    371371                q{update %s set value = ? where okey = ? and attr = ?}, 
    372                 $self->db->quote_identifier($self->object_table. '_attributes'), 
     372                $self->db->quote_identifier($self->_object_table. '_attributes'), 
    373373            ) 
    374374        ); 
     
    474474                q{select %s as value from %s}, 
    475475                $base->db->quote_identifier($attr->iname), 
    476                 $base->db->quote_identifier($class->object_table), 
     476                $base->db->quote_identifier($class->_object_table), 
    477477            ) 
    478478            : sprintf( 
    479479                q{select value from %s where attr = ? group by value}, 
    480                 $base->db->quote_identifier($class->object_table . 
     480                $base->db->quote_identifier($class->_object_table . 
    481481                    '_attributes'), 
    482482            ) 
     
    548548            $sql = sprintf( 
    549549                q{select ikey from %s where %s}, 
    550                 $base->db->quote_identifier($class->object_table), 
     550                $base->db->quote_identifier($class->_object_table), 
    551551                $val ? q{exported='f'} : q{exported='t'} 
    552552            ) 
     
    554554            $sql = sprintf( 
    555555                q{select ikey from %s where %s %s}, 
    556                 $base->db->quote_identifier($class->object_table), 
     556                $base->db->quote_identifier($class->_object_table), 
    557557                $base->db->quote_identifier($attribute->iname), 
    558558                $val eq '*' 
     
    567567                q{select okey from %s where attr = ? %s}, 
    568568                $base->db->quote_identifier( 
    569                     $class->object_table . '_attributes' 
     569                    $class->_object_table . '_attributes' 
    570570                ), 
    571571                $val eq '*' 
     
    587587        push(@sqlintersec, sprintf( 
    588588                q{select ikey from %s where exported = true}, 
    589                 $base->db->quote_identifier($class->object_table) 
     589                $base->db->quote_identifier($class->_object_table) 
    590590            ) 
    591591        ); 
     
    602602            order by name 
    603603            }, 
    604             $base->db->quote_identifier($class->object_table), 
     604            $base->db->quote_identifier($class->_object_table), 
    605605            @sqlintersec  
    606606            ? "where ikey in (\n" . join("\n intersect\n", @sqlintersec) . ")\n" 
     
    627627            insert into %s (canonical, description) 
    628628            values (?,?) 
    629             }, $class->attributes_table) 
     629            }, $class->_attributes_table) 
    630630    ); 
    631631    my $res = $sth->execute($attribute, $comment); 
     
    638638        sprintf(q{ 
    639639            select 1 from %s where canonical = ? 
    640             }, $class->attributes_table 
     640            }, $class->_attributes_table 
    641641        ) 
    642642    ); 
     
    656656            select description from %s 
    657657            where canonical = ? 
    658             }, $class->attributes_table) 
     658            }, $class->_attributes_table) 
    659659    ); 
    660660    $sth->execute($attribute); 
     
    684684            update %s set description = ? 
    685685            where canonical = ? 
    686             }, $class->attributes_table) 
     686            }, $class->_attributes_table) 
    687687    ); 
    688688    my $res = $sth->execute($comment, $attribute); 
Note: See TracChangeset for help on using the changeset viewer.