Skip to content

Commit

Permalink
Enhancements to External.pm
Browse files Browse the repository at this point in the history
* This is little-known core module, but can allow command-line access to
  Interchange, and other uses.
* Add failure on env
* Add logError sub
* Default IP address
  • Loading branch information
Josh Lavin committed Dec 8, 2015
1 parent f9ab4cc commit d461a47
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/Vend/External.pm
Expand Up @@ -33,6 +33,9 @@ BEGIN {
$ENV{MINIVEND_STORABLE} = 1;
}
}
else {
die "Cannot proceed: EXT_INTERCHANGE_DIR environment variable is not defined.\n";
}
}

use Vend::Util;
Expand Down Expand Up @@ -79,6 +82,10 @@ BEGIN {
warn caller() . ':external_debug: ', Vend::Util::errmsg(@_), "\n";
}

sub logError {
die caller() . ':external_error: ', Vend::Util::errmsg(@_), "\n";
}

sub catalog {
my $cat = shift or return $Vend::Cat;
$Vend::Cat = $cat;
Expand All @@ -90,7 +97,7 @@ BEGIN {
or die "No Interchange catalog specified\n";
$Vend::Cfg = $Vend::Global->{Catalogs}{$Vend::Cat}{external_config}
or die "Catalog $Vend::Cat not found.\n";
$CGI::remote_addr = $ENV{REMOTE_ADDR};
$CGI::remote_addr = $ENV{REMOTE_ADDR} || '127.0.0.1';
if($id =~ /^(\w+):/) {
$Vend::SessionID = $1;
$Vend::SessionName = $id;
Expand Down

0 comments on commit d461a47

Please sign in to comment.