[interchange-cvs] interchange - jon modified 3 files

interchange-cvs at icdevgroup.org interchange-cvs at icdevgroup.org
Mon Jan 31 21:07:15 EST 2005


User:      jon
Date:      2005-02-01 02:07:15 GMT
Modified:  lib/Vend Config.pm Interpolate.pm Session.pm
Log:
Patch from Ethan Rowe <ethan at endpoint.com>:

Update the DiscountSpaceVar configuration directive to allow for an
array of different CGI variable names. These are the names of CGI
variables that will be checked per page process in order to determine
the initial discount namespace; defaults to 'main' if the CGI variables
are empty/undefined. The discount space initialization logic based on
CGI variables will only be used for catalogs in which the DiscountSpaces
directive is set to true ("yes").

Tied the session {discount} member to the current discount
namespace subhash from {discount_space}{<spacename>} to maximize
compatibility of discount namespaces with existing code dependent
upon $Session->{discount}; switching the discount namespace will
always result in $::Discounts = $Vend::Session->{discount} =
$Vend::Session->{discount_space}{<SPACENAME>} ||= {};

Updated read_session to ensure that $::Discounts and
$Vend::Session->{discount} always refer to the default ('main') discount
namespace from $Vend::Session->{discount_space}{main} at the start of
page processing.

Revision  Changes    Path
2.154     +18 -9     interchange/lib/Vend/Config.pm


rev 2.154, prev_rev 2.153
Index: Config.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Config.pm,v
retrieving revision 2.153
retrieving revision 2.154
diff -u -u -r2.153 -r2.154
--- Config.pm	30 Jan 2005 16:36:29 -0000	2.153
+++ Config.pm	1 Feb 2005 02:07:14 -0000	2.154
@@ -1,6 +1,6 @@
 # Vend::Config - Configure Interchange
 #
-# $Id: Config.pm,v 2.153 2005/01/30 16:36:29 mheins Exp $
+# $Id: Config.pm,v 2.154 2005/02/01 02:07:14 jon Exp $
 #
 # Copyright (C) 2002-2003 Interchange Development Group
 # Copyright (C) 1996-2002 Red Hat, Inc.
@@ -49,7 +49,7 @@
 use Vend::File;
 use Vend::Data;
 
-$VERSION = substr(q$Revision: 2.153 $, 10);
+$VERSION = substr(q$Revision: 2.154 $, 10);
 
 my %CDname;
 my %CPname;
@@ -553,7 +553,7 @@
 	['PriceDefault',	 undef,              'price'],
 	['PriceField',		 undef,              'price'],
 	['DiscountSpaces',	 'yesno',            'no'],
-	['DiscountSpaceVar', 'word',             'mv_discount_space'],
+	['DiscountSpaceVar', 'array',            'mv_discount_space'],
 	['Jobs',		 	 'hash',     	 	 ''],
 	['Shipping',         'locale',           ''],
 	['Accounting',	 	 'locale',     	 	 ''],
@@ -2359,10 +2359,12 @@
 );
 
 %Dispatch_code = (
+
 	Autoload => sub {
 #::logDebug("Doing Autoload dispatch...");
 		Vend::Dispatch::run_macro($Vend::Cfg->{Autoload});
 	},
+
 	CookieLogin => sub {
 #::logDebug("Doing CookieLogin dispatch....");
 		if(! $Vend::Session->{logged_in}) {
@@ -2390,6 +2392,7 @@
 			}
 		}
 	},
+
 	Locale => sub {
 #::logDebug("Doing Locale dispatch...");
 		my $locale = $::Scratch->{mv_locale}
@@ -2409,18 +2412,24 @@
 								{ persist => 1 }
 							);
 	},
+
 	DiscountSpaces => sub {
 #::logDebug("Doing DiscountSpaces dispatch...");
-	   if ($CGI::values{$Vend::Cfg->{DiscountSpaceVar}}) {
-#::logDebug("$Vend::Cfg->{DiscountSpaceVar} is set=...");
-           $Vend::DiscountSpace = $CGI::values{$Vend::Cfg->{DiscountSpaceVar}};
-#::logDebug("$Vend::Cfg->{DiscountSpaceVar} is set=$Vend::DiscountSpace...");
-		   $::Discounts
+		my $dspace;
+		for (@{$Vend::Cfg->{DiscountSpaceVar}}) {
+			next unless $dspace = $CGI::values{$_};
+#::logDebug("$_ is set=...");
+			last;
+		}
+		return unless $dspace;
+		$Vend::DiscountSpace = $dspace;
+#::logDebug("Discount space is set=$Vend::DiscountSpace...");
+		$::Discounts
 				= $Vend::Session->{discount}
 				= $Vend::Session->{discount_space}{$Vend::DiscountSpace}
 				||= {};
-        }
     },
+
 );
 
 # Set up defaults for certain directives



2.232     +8 -5      interchange/lib/Vend/Interpolate.pm


rev 2.232, prev_rev 2.231
Index: Interpolate.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Interpolate.pm,v
retrieving revision 2.231
retrieving revision 2.232
diff -u -u -r2.231 -r2.232
--- Interpolate.pm	25 Jan 2005 04:17:58 -0000	2.231
+++ Interpolate.pm	1 Feb 2005 02:07:15 -0000	2.232
@@ -1,6 +1,6 @@
 # Vend::Interpolate - Interpret Interchange tags
 # 
-# $Id: Interpolate.pm,v 2.231 2005/01/25 04:17:58 mheins Exp $
+# $Id: Interpolate.pm,v 2.232 2005/02/01 02:07:15 jon Exp $
 #
 # Copyright (C) 2002-2005 Interchange Development Group
 # Copyright (C) 1996-2002 Red Hat, Inc.
@@ -28,7 +28,7 @@
 require Exporter;
 @ISA = qw(Exporter);
 
-$VERSION = substr(q$Revision: 2.231 $, 10);
+$VERSION = substr(q$Revision: 2.232 $, 10);
 
 @EXPORT = qw (
 
@@ -2662,7 +2662,9 @@
 #::logDebug('switch_discount_space: initialized discount space hash.');
 	}
 	if ($dspace ne ($oldspace = $Vend::DiscountSpace)) {
-		$::Discounts = $Vend::Session->{discount_space}{$Vend::DiscountSpace = $dspace};
+		$::Discounts = $Vend::Session->{discount}
+			= $Vend::Session->{discount_space}{$Vend::DiscountSpace = $dspace}
+			||= {};
 #::logDebug("switch_discount_space: changed discount space from '$oldspace' to $Vend::DiscountSpace");
 	}
 	return $oldspace;
@@ -4912,8 +4914,9 @@
 
 	if ($extra and ! $::Discounts) {
 		my $dspace = $Vend::DiscountSpace ||= 'main';
-		$Vend::Session->{discount_space}{main} = $Vend::Session->{discount} ||= {};
-		$::Discounts = $Vend::Session->{discount_space}{$dspace} ||= {};
+		$Vend::Session->{discount_space}{main} = $Vend::Session->{discount} ||= {}
+			unless $Vend::Session->{discount_space}{main};
+		$::Discounts = $Vend::Session->{discount} = $Vend::Session->{discount_space}{$dspace} ||= {};
 	}
 
 	return $price unless $::Discounts;



2.21      +4 -2      interchange/lib/Vend/Session.pm


rev 2.21, prev_rev 2.20
Index: Session.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Session.pm,v
retrieving revision 2.20
retrieving revision 2.21
diff -u -u -r2.20 -r2.21
--- Session.pm	19 Jul 2004 22:34:45 -0000	2.20
+++ Session.pm	1 Feb 2005 02:07:15 -0000	2.21
@@ -1,6 +1,6 @@
 # Vend::Session - Interchange session routines
 #
-# $Id: Session.pm,v 2.20 2004/07/19 22:34:45 jon Exp $
+# $Id: Session.pm,v 2.21 2005/02/01 02:07:15 jon Exp $
 # 
 # Copyright (C) 2002-2003 Interchange Development Group
 # Copyright (C) 1996-2002 Red Hat, Inc.
@@ -27,7 +27,7 @@
 require Exporter;
 
 use vars qw($VERSION);
-$VERSION = substr(q$Revision: 2.20 $, 10);
+$VERSION = substr(q$Revision: 2.21 $, 10);
 
 @ISA = qw(Exporter);
 
@@ -433,6 +433,8 @@
     $::Values	= $Vend::Session->{values};
     $::Scratch	= $Vend::Session->{scratch};
     $::Carts	= $Vend::Session->{carts};
+	$::Discounts = $Vend::Session->{discount}
+		= $Vend::Session->{discount_space}{main} ||= {};
     $Vend::Interpolate::Tmp ||= {};
     $::Control	= $Vend::Interpolate::Tmp->{control} = [];
 	tie $Vend::Items, 'Vend::Cart';








More information about the interchange-cvs mailing list