SubCatalog — register subcatalog with the Interchange server
The directive allows definition of "subcatalogs" — catalogs that
share most of the characteristics of
another, "base" catalog.
In a SubCatalog setup, the appropriate catalog.cfg should only contain
directives that differ from definitions in the base catalog's catalog.cfg.
Interchange's subcatalogs feature isn't used much, but primary reasons for its use would be memory savings, or some kind of chained-configuration catalogs.
Concerning the directive arguments, subcatalog_name and
base_catalog_name are the names of the new and existing
catalog respectively. catalog_directory (CATROOT)
defines the catalog root directory, and can be the same for both the master-
and sub-catalog. Finally, the link program is a webserver path by
which the subcatalog can be accessed.
Example: Registering a sub catalog
Catalog simple /home/catalogs/simple /cgi-bin/ic/simple SubCatalog subsimple simple /home/catalogs/simple /cgi-bin/ic/subsimple
Interchange 5.9.0:
Source: lib/Vend/Config.pm
Line 4147 (context shows lines 4147-4248)
sub parse_catalog {
my ($var, $setting) = @_;
my $num = ! defined $Global::Catalog ? 0 : $Global::Catalog;
return $num unless (defined $setting && $setting);
my($name,$base,$dir,$script, @rest);
($name,@rest) = Text::ParseWords::shellwords($setting);
my %remap = qw/
base base
alias alias
aliases alias
directory dir
dir dir
script script
directive directive
fullurl full_url
full full_url
/;
my ($cat, $key, $value);
if ($Global::Catalog{$name}) {
# already defined
$cat = $Global::Catalog{$name};
$key = shift @rest;
$value = shift @rest;
}
elsif(
$var =~ /subcatalog/i and
@rest > 2
and file_name_is_absolute($rest[1])
)
{
$cat = {
name => $name,
base => $rest[0],
dir => $rest[1],
script => $rest[2],
};
splice(@rest, 0, 3);
$cat->{alias} = [ @rest ]
if @rest;
}
elsif( file_name_is_absolute($rest[0]) ) {
$cat = {
name => $name,
dir => $rest[0],
script => $rest[1],
};
splice(@rest, 0, 2);
$cat->{alias} = [ @rest ]
if @rest;
}
else {
$key = shift @rest;
$value = shift @rest;
$cat = { name => $name };
}
$key = $remap{$key} if $key && defined $remap{$key};
if(! $key) {
# Nada
}
elsif($key eq 'alias' or $key eq 'server') {
$cat->{$key} = [] if ! $cat->{$key};
push @{$cat->{$key}}, $value;
push @{$cat->{$key}}, @rest if @rest;
}
elsif($key eq 'global') {
$cat->{$key} = $Global::AllowGlobal->{$name} = is_yes($value);
}
elsif($key eq 'directive') {
no strict 'refs';
my $p = $value;
my $v = join " ", @rest;
$cat->{$key} = {} if ! $cat->{$key};
my $ref = set_directive($p, $v, 1);
if(ref $ref->[1] =~ /HASH/) {
if(! $cat->{$key}{$ref->[0]} ) {
$cat->{$key}{$ref->[0]} = { %{"Global::$ref->[0]"} };
}
for (keys %{$ref->[1]}) {
$cat->{$key}{$ref->[0]}{$_} = $ref->[1]->{$_};
}
}
else {
$cat->{$key}{$ref->[0]} = $ref->[1];
}
}
else {
$cat->{$key} = $value;
}
#::logDebug ("parsing catalog $name = " . uneval_it($cat));
$Global::Catalog{$name} = $cat;
# Define the main script name and array of aliases
return ++$num;
}