[interchange] Enhancements to External.pm

Josh Lavin interchange-cvs at icdevgroup.org
Tue Dec 8 22:49:22 UTC 2015


commit d461a475af32bde11696ec2b84c8b7e16856d67e
Author: Josh Lavin <jlavin at endpoint.com>
Date:   Tue Dec 8 14:48:09 2015 -0800

    Enhancements to External.pm
    
    * 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

 lib/Vend/External.pm |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/lib/Vend/External.pm b/lib/Vend/External.pm
index b6596e2..27f5cd2 100644
--- a/lib/Vend/External.pm
+++ b/lib/Vend/External.pm
@@ -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;
@@ -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;
@@ -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;



More information about the interchange-cvs mailing list