DirectiveDatabase — specify database to read configuration directives from
The DirectiveDatabase
configuration directive makes it possible to
read all configuration directives from a database, instead of
from the usual catalog.cfg
configuration file.
The database can (but does not have to) be previously defined with
the Database
directive. When it is, then just the table name
is required and honored. When it is not, then the Database
directive
will be automatically invoked first to register the new table, possibly with
custom text source file and table type.
table_source_filename
defaults to
, and
table_name
.txttable_source_type
defaults to TAB
.
(The arguments are the same as for the Database
directive itself,
they are passed to it directly.)
Example: Defining DirectiveDatabase, two-step
Database catalog catalog.txt TAB DirectiveDatabase catalog
Interchange 5.9.0:
Source: lib/Vend/Config.pm
Line 4769 (context shows lines 4769-4815)
sub parse_dbconfig { my ($var, $value) = @_; my ($file, $type); return '' if ! $value; local($Vend::Cfg) = $C; my ($db, $table); eval { ($db, $table) = get_configdb($var, $value); }; return '' if ! $db; my ($k, @f); # key and fields my @l; # refs to locale repository my @n; # names of locales my @h; # names of locales @n = $db->columns(); shift @n; my $extra; for(@n) { my $real = $CDname{lc $_}; if (! ref $Vend::Cfg->{$real} or $Vend::Cfg->{$real} !~ /HASH/) { # ignore non-existent directive, but put in hash my $ref = {}; push @l, $ref; push @h, [$real, $ref]; next; } push @l, $Vend::Cfg->{$real}; } my $i; while( ($k, undef, @f ) = $db->each_record) { #::logDebug("Got key=$k f=@f"); for ($i = 0; $i < @f; $i++) { next unless length($f[$i]); $l[$i]->{$k} = $f[$i]; } } for(@h) { $Vend::Cfg->{Hash}{$_->[0]} = $_->[1]; } $db->close_table(); return $table; }