[interchange-cvs] interchange - heins modified 4 files
interchange-cvs at icdevgroup.org
interchange-cvs at icdevgroup.org
Thu Sep 22 12:37:53 EDT 2005
User: heins
Date: 2005-09-22 16:37:52 GMT
Modified: lib/Vend Data.pm Order.pm
Modified: dist/test/products products2.asc tests.asc
Log:
* Improve ability of AutoModifier, make consistent in both places where
it can be set.
* Current variations:
AutoModifier category
AutoModifier outboard:category
AutoModifier outboard:category:foreign
all stay the same -- only difference is that :: is now accepted same as :.
* New variation:
AutoModifier attribute=table:column
AutoModifier attribute=table:column:foreign
is accepted. This removes the requirement that the attribute be named
the same thing as the table column.
* Added regression test that checks all of the above.
* Will look for existing documentation to update.
* Your regression tests will require a "rm products/products2.sql" to
update the data for that table.
Revision Changes Path
2.53 +18 -3 interchange/lib/Vend/Data.pm
rev 2.53, prev_rev 2.52
Index: Data.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Data.pm,v
retrieving revision 2.52
retrieving revision 2.53
diff -u -r2.52 -r2.53
--- Data.pm 24 Aug 2005 19:41:19 -0000 2.52
+++ Data.pm 22 Sep 2005 16:37:52 -0000 2.53
@@ -1,6 +1,6 @@
# Vend::Data - Interchange databases
#
-# $Id: Data.pm,v 2.52 2005/08/24 19:41:19 jon Exp $
+# $Id: Data.pm,v 2.53 2005/09/22 16:37:52 mheins Exp $
#
# Copyright (C) 2002-2004 Interchange Development Group
# Copyright (C) 1996-2002 Red Hat, Inc.
@@ -1702,12 +1702,27 @@
)
{
foreach my $i (@{$Vend::Cfg->{AutoModifier}}) {
- my ($table,$key) = split /:/, $i;
+ my $attr;
+ my ($table,$key,$foreign) = split /:+/, $i, 3;
+
+ if($table =~ /=/) {
+ ($attr, $table) = split /\s*=\s*/, $table, 2;
+ }
+
unless ($key) {
$key = $table;
$table = $item->{mv_ib};
}
- $item->{$key} = ::tag_data($table, $key, $item->{code});
+
+ $attr ||= $key;
+ $table ||= $Vend::Cfg->{ProductFiles}[0];
+
+ my $select = $foreign ? $item->{$foreign} : $item->{code};
+ $select ||= $item->{code};
+
+#::logDebug("attr=$attr table=$table key=$key select=$select foreign=$foreign");
+ $item->{$attr} = ::tag_data($table, $key, $select);
+#::logDebug("item->$attr=$item->{$attr}");
}
#::logDebug("item=" . ::uneval($item));
}
2.74 +20 -8 interchange/lib/Vend/Order.pm
rev 2.74, prev_rev 2.73
Index: Order.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Order.pm,v
retrieving revision 2.73
retrieving revision 2.74
diff -u -r2.73 -r2.74
--- Order.pm 16 Sep 2005 18:55:19 -0000 2.73
+++ Order.pm 22 Sep 2005 16:37:52 -0000 2.74
@@ -1,6 +1,6 @@
# Vend::Order - Interchange order routing routines
#
-# $Id: Order.pm,v 2.73 2005/09/16 18:55:19 mheins Exp $
+# $Id: Order.pm,v 2.74 2005/09/22 16:37:52 mheins Exp $
#
# Copyright (C) 2002-2003 Interchange Development Group
# Copyright (C) 1996-2002 Red Hat, Inc.
@@ -29,7 +29,7 @@
package Vend::Order;
require Exporter;
-$VERSION = substr(q$Revision: 2.73 $, 10);
+$VERSION = substr(q$Revision: 2.74 $, 10);
@ISA = qw(Exporter);
@@ -2587,15 +2587,27 @@
}
if($Vend::Cfg->{AutoModifier}) {
foreach $i (@{$Vend::Cfg->{AutoModifier}}) {
- my ($table,$key,$attrib) = split /:/, $i;
- my $select = $attrib ? $item->{$attrib} : $code;
+ my $attr;
+ my ($table,$key,$foreign) = split /:+/, $i, 3;
+
+ if($table =~ /=/) {
+ ($attr, $table) = split /\s*=\s*/, $table, 2;
+ }
+
unless ($key) {
$key = $table;
- $item->{$key} = item_common($item, $key, $select)
- }
- else {
- $item->{$key} = tag_data($table, $key, $select);
+ $table = $item->{mv_ib};
}
+
+ $attr ||= $key;
+
+
+ my $select = $foreign ? $item->{$foreign} : $code;
+ $select ||= $code;
+
+#::logDebug("attr=$attr table=$table key=$key select=$select foreign=$foreign");
+ $item->{$attr} = ::tag_data($table, $key, $select);
+#::logDebug("item->$attr=$item->{$attr}");
}
}
2.1 +2 -1 interchange/dist/test/products/products2.asc
rev 2.1, prev_rev 2.0
Index: products2.asc
===================================================================
RCS file: /var/cvs/interchange/dist/test/products/products2.asc,v
retrieving revision 2.0
retrieving revision 2.1
diff -u -r2.0 -r2.1
--- products2.asc 18 Jul 2001 02:22:35 -0000 2.0
+++ products2.asc 22 Sep 2005 16:37:52 -0000 2.1
@@ -1,5 +1,5 @@
code|description|title|artist|comment|display|image|price|category|nontaxable|weight|size|color
-00-0011|XXXX MONA LISA, Da Vinci|Mona Lisa|Leonardo Da Vinci|What was she smiling about?|The Louvre|00-0011.jpg|49999995|Renaissance|no|8||
+00-0011|XXXX MONA LISA, Da Vinci|Mona Lisa|Leonardo Da Vinci|What was she smiling about?|The Louvre|00-0011.jpg|49999995|Renaissance XXXX|no|8||
00-0011a|XXXX Gilded Frame signed by Da Vinci|Frame|Gilded||||1000|Accessory|1|20||
00-343|XXXX PERSISTENCE OF MEMORY, Dali|Persistence of Memory|Salvador Dali|How does he do that? |MOMA|00-343.jpg|20000000|Surrealists|no|10||
19-202|XXXX RADIOACTIVE CATS, Sandy Skoglund|Radioactive Cats|Sandy Skoglund|What is wrong with this picture?|Getty Museum|radcats1.gif|400000|Contemporary|no|30||
@@ -8,3 +8,4 @@
34-101|XXXX FAMILY PORTRAIT, by Langan|Family Portrait|Jean Langan|Haunting view of Grandma's Parlor|Krannert|34-101.gif|1000000|Americana|no|10||
00-341|XXXX SUNFLOWERS, by Van Gogh|Sunflowers|Vincent Van Gogh|An exquisite painting showing Van Gogh at the height of his pointillist powers.|The Louvre|00-341.jpg|40000000|Impressionists|no|40||
X0-342|XXXX THE STARRY NIGHT, Van Gogh|2-The Starry Night|Vincent Van Gogh|Breathtaking example of Van Gogh's work.|MOMA|00-342.jpg|20000000|Impressionists|no|10||
+Renaissance|XXXX MONA LISA, Da Vinci|Mona Lisa|Leonardo Da Vinci|What was she smiling about?|The Louvre|00-0011.jpg|49999995|Renaissance YYYY|no|8||
2.23 +19 -0 interchange/dist/test/products/tests.asc
rev 2.23, prev_rev 2.22
Index: tests.asc
===================================================================
RCS file: /var/cvs/interchange/dist/test/products/tests.asc,v
retrieving revision 2.22
retrieving revision 2.23
diff -u -r2.22 -r2.23
--- tests.asc 9 Jun 2005 19:38:36 -0000 2.22
+++ tests.asc 22 Sep 2005 16:37:52 -0000 2.23
@@ -2802,6 +2802,25 @@
%%
Check the if 'control' conditional type.
%%%
+000159
+%%
+[perl]
+ @{$Carts->{main}} = ();
+ $Config->{AutoModifier} = ['products:category', 'category2=products2:category', 'category3=products2:category:category'];
+ $CGI->{mv_order_item} = '00-0011';
+ return;
+[/perl]
+[update values]
+[item-list][item-code] [item-modifier category] [item-modifier category2] [item-modifier category3][/item-list]
+%%
+Renaissance\s+Renaissance\s+XXXX\s+Renaissance\s+YYYY
+%%
+^\s*$]
+%%
+
+%%
+Test AutoModifier with variations.
+%%%
999999
%%
[the test] [perl]
More information about the interchange-cvs
mailing list