[interchange-cvs] interchange - heins modified lib/Vend/Dispatch.pm

interchange-cvs at icdevgroup.org interchange-cvs at icdevgroup.org
Sat Jul 22 13:04:29 EDT 2006


User:      heins
Date:      2006-07-22 17:04:28 GMT
Modified:  lib/Vend Dispatch.pm
Log:
* Add hook for catalog_init subroutine that gives you access before the
  session assignment is done. In this case, it was used to modify the
  name of session files so you can assign a session number based on the
  HTTP_SERVER_HOST coming in -- but it could be used for a number of
  purposes.

  Uses the usual SpecialSub method:

  	Sub my_init sub { $CGI::user = $CGI::server_host }
	SpecialSub catalog_init my_init

Revision  Changes    Path
1.70      +16 -2     interchange/lib/Vend/Dispatch.pm


rev 1.70, prev_rev 1.69
Index: Dispatch.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Dispatch.pm,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -r1.69 -r1.70
--- Dispatch.pm	27 Jun 2006 14:24:42 -0000	1.69
+++ Dispatch.pm	22 Jul 2006 17:04:28 -0000	1.70
@@ -1,6 +1,6 @@
 # Vend::Dispatch - Handle Interchange page requests
 #
-# $Id: Dispatch.pm,v 1.69 2006/06/27 14:24:42 racke Exp $
+# $Id: Dispatch.pm,v 1.70 2006/07/22 17:04:28 mheins Exp $
 #
 # Copyright (C) 2002-2006 Interchange Development Group
 # Copyright (C) 2002 Mike Heins <mike at perusion.net>
@@ -26,7 +26,7 @@
 package Vend::Dispatch;
 
 use vars qw($VERSION);
-$VERSION = substr(q$Revision: 1.69 $, 10);
+$VERSION = substr(q$Revision: 1.70 $, 10);
 
 use POSIX qw(strftime);
 use Vend::Util;
@@ -1125,6 +1125,20 @@
 
 #show_times("end cgi and config mapping") if $Global::ShowTimes;
 	open_database();
+
+	if (my $subname = $Vend::Cfg->{SpecialSub}{catalog_init}) {
+#::logDebug(errmsg("running subroutine '%s' for %s", $subname, 'catalog_init'));
+		my $sub = $Vend::Cfg->{Sub}{$subname} || $Global::GlobalSub->{$subname};
+		my $status;
+		eval {
+			$status = $sub->();
+		};
+
+		if($@) {
+			::logError("Error running %s subroutine %s: %s", 'catalog_init', $subname, $@);
+		}
+	}
+
 #show_times("end open_database") if $Global::ShowTimes;
 	return 1;
 }








More information about the interchange-cvs mailing list