[interchange-cvs] interchange - heins modified 3 files
interchange-core@interchange.redhat.com
interchange-core@interchange.redhat.com
Mon Jan 21 21:08:01 2002
User: heins
Date: 2002-01-22 02:07:08 GMT
Modified: lib/Vend Config.pm Session.pm Util.pm
Log:
* Add new PageTables capability. Includes:
-- PageTables directive in Config.pm (enables/routes PageTables)
-- PageTableMap directive in Config.pm (to map field names)
-- Support for database read of pages in Vend::Util::readin
-- "Teleport" mode which reads a page as it was/is at a particular
time.
This capablity theoretically would work with GDBM databases but
you would never want to use it that way.
Basically, if you place a record in the table "PageTables" with a
key of "index", a read of that key in the page table will pre-empt
a read from any PageDir or TemplateDir .
If you set Vend::Session->{teleport} to a %Y%h%m%H%M time value,
it will return pages with a show_date earlier than that value
and an expiration date later than that value. In the case of
a tie, the later show_date wins.
PageTableMap allows you to remap field names if desired; not
recommended as UI may not honor mapping to begin with, but
makes remap possible.
* Move Control space to Vend::Interpolate::Tmp to prevent
storage in session. Also, allows multiple control spaces
to be set up (for nesting).
Revision Changes Path
2.21 +10 -2 interchange/lib/Vend/Config.pm
rev 2.21, prev_rev 2.20
Index: Config.pm
===================================================================
RCS file: /anon_cvs/repository/interchange/lib/Vend/Config.pm,v
retrieving revision 2.20
retrieving revision 2.21
diff -u -r2.20 -r2.21
--- Config.pm 2002/01/16 02:28:25 2.20
+++ Config.pm 2002/01/22 02:07:08 2.21
@@ -1,6 +1,6 @@
# Vend::Config - Configure Interchange
#
-# $Id: Config.pm,v 2.20 2002/01/16 02:28:25 jon Exp $
+# $Id: Config.pm,v 2.21 2002/01/22 02:07:08 mheins Exp $
#
# Copyright (C) 1996-2001 Red Hat, Inc. <interchange@redhat.com>
#
@@ -95,7 +95,7 @@
use Vend::Parse;
use Vend::Util;
-$VERSION = substr(q$Revision: 2.20 $, 10);
+$VERSION = substr(q$Revision: 2.21 $, 10);
my %CDname;
@@ -382,6 +382,14 @@
['Profile', 'locale', ''],
['ValuesDefault', 'hash', ''],
['ProductFiles', 'array_complete', 'products'],
+ ['PageTables', 'array_complete', ''],
+ ['PageTableMap', 'hash', qq{
+ expiration_date expiration_date
+ show_date show_date
+ page_text page_text
+ base_page base_page
+ code code
+ }],
['DisplayErrors', 'yesno', 'No'],
['ParseVariables', 'yesno', 'No'],
['SpecialPage', 'special', 'order ord/basket results results search results flypage flypage'],
2.2 +4 -3 interchange/lib/Vend/Session.pm
rev 2.2, prev_rev 2.1
Index: Session.pm
===================================================================
RCS file: /anon_cvs/repository/interchange/lib/Vend/Session.pm,v
retrieving revision 2.1
retrieving revision 2.2
diff -u -r2.1 -r2.2
--- Session.pm 2001/11/15 00:53:04 2.1
+++ Session.pm 2002/01/22 02:07:08 2.2
@@ -1,6 +1,6 @@
# Vend::Session - Interchange session routines
#
-# $Id: Session.pm,v 2.1 2001/11/15 00:53:04 mheins Exp $
+# $Id: Session.pm,v 2.2 2002/01/22 02:07:08 mheins Exp $
#
# Copyright (C) 1996-2001 Red Hat, Inc. <interchange@redhat.com>
#
@@ -26,7 +26,7 @@
require Exporter;
use vars qw($VERSION);
-$VERSION = substr(q$Revision: 2.1 $, 10);
+$VERSION = substr(q$Revision: 2.2 $, 10);
@ISA = qw(Exporter);
@@ -384,7 +384,8 @@
$::Values = $Vend::Session->{'values'};
$::Scratch = $Vend::Session->{scratch};
$::Carts = $Vend::Session->{carts};
- $::Control = $Vend::Session->{control} = [];
+ $Vend::Interpolate::Tmp ||= {};
+ $::Control = $Vend::Interpolate::Tmp->{control} = [];
tie $Vend::Items, 'Vend::Cart';
}
2.13 +49 -6 interchange/lib/Vend/Util.pm
rev 2.13, prev_rev 2.12
Index: Util.pm
===================================================================
RCS file: /anon_cvs/repository/interchange/lib/Vend/Util.pm,v
retrieving revision 2.12
retrieving revision 2.13
diff -u -r2.12 -r2.13
--- Util.pm 2002/01/16 01:54:09 2.12
+++ Util.pm 2002/01/22 02:07:08 2.13
@@ -1,6 +1,6 @@
# Vend::Util - Interchange utility functions
#
-# $Id: Util.pm,v 2.12 2002/01/16 01:54:09 jon Exp $
+# $Id: Util.pm,v 2.13 2002/01/22 02:07:08 mheins Exp $
#
# Copyright (C) 1996-2001 Red Hat, Inc. <interchange@redhat.com>
#
@@ -81,7 +81,7 @@
use Safe;
use subs qw(logError logGlobal);
use vars qw($VERSION @EXPORT @EXPORT_OK);
-$VERSION = substr(q$Revision: 2.12 $, 10);
+$VERSION = substr(q$Revision: 2.13 $, 10);
BEGIN {
eval {
@@ -883,6 +883,29 @@
return $text;
}
+sub teleport_name {
+ my ($file, $teleport, $table) = @_;
+ my $db;
+ return $file
+ unless $teleport
+ and $db = Vend::Data::database_exists_ref($table);
+
+ my @f = qw/code base_code expiration_date show_date page_text/;
+ my ($c, $bc, $ed, $sd, $pt) = @{$Vend::Cfg->{PageTableMap}}{@f};
+ my $q = qq{
+ SELECT $c from $table
+ WHERE $bc = '$file'
+ AND $ed < $teleport
+ AND $sd >= $teleport
+ ORDER BY $sd DESC
+ };
+ my $ary = $db->query($q);
+ if($ary and $ary->[0]) {
+ $file = $ary->[0][0];
+ }
+ return $file;
+}
+
# Reads in a page from the page directory with the name FILE and ".html"
# appended. If the HTMLsuffix configuration has changed (because of setting in
# catalog.cfg or Locale definitions) it will substitute that. Returns the
@@ -890,7 +913,7 @@
# Substitutes Locale bits as necessary.
sub readin {
- my($file, $only) = @_;
+ my($file, $only, $locale) = @_;
## We don't want to try if we are forcing a flypage
return undef if $Vend::ForceFlypage;
@@ -913,7 +936,27 @@
$pathdir =~ s:^/+::;
my $try;
my $suffix = $Vend::Cfg->{HTMLsuffix};
+ my $db_tried;
+ $locale = 1 unless defined $locale;
+ my $record;
FINDPAGE: {
+ ## If PageTables is set, we try to find the page in the table first
+ ## but only once, without the suffix
+ if(! $db_tried++ and $Vend::Cfg->{PageTables}) {
+ my $teleport = $Vend::Session->{teleport};
+ my $field = $Vend::Cfg->{PageTableMap}{page_text};
+ foreach my $t (@{$Vend::Cfg->{PageTables}}) {
+ my $db = Vend::Data::database_exists_ref($t);
+ if($teleport) {
+ $file = teleport_name($file, $teleport, $t);
+ }
+ $record = $db->row_hash($file)
+ or next;
+ $contents = $record->{$field};
+ last FINDPAGE if length $contents;
+ undef $contents;
+ }
+ }
foreach $try (
$Vend::Cfg->{PageDir},
@{$Vend::Cfg->{TemplateDir}},
@@ -976,7 +1019,7 @@
return unless defined $contents;
- if($Vend::Cfg->{Locale}) {
+ if($locale and $Vend::Cfg->{Locale}) {
my $key;
$contents =~ s~\[L(\s+([^\]]+))?\]([\000-\377]*?)\[/L\]~
$key = $2 || $3;
@@ -990,7 +1033,8 @@
$contents =~ s~\[L(?:\s+[^\]]+)?\]([\000-\377]*?)\[/L\]~$1~g;
}
- return $contents;
+ return $contents unless wantarray;
+ return ($contents, $record);
}
sub readfile_db {
@@ -1708,7 +1752,6 @@
);
}
}
-
# Front-end to log routines that ignores repeated identical
# log messages after the first occurrence