[interchange-cvs] interchange - racke modified 5 files

interchange-core@interchange.redhat.com interchange-core@interchange.redhat.com
Sat May 25 09:28:02 2002


User:      racke
Date:      2002-05-25 13:27:58 GMT
Modified:  .        MANIFEST
Modified:  lib/Vend Config.pm Data.pm
Modified:  scripts  interchange.PL
Added:     lib/Vend/Table Shadow.pm
Log:
initial checkin of the new Shadow database type - this is not
doing anything useful yet, but I want to give a heads up on that

Revision  Changes    Path
2.38      +1 -0      interchange/MANIFEST


rev 2.38, prev_rev 2.37
Index: MANIFEST
===================================================================
RCS file: /anon_cvs/repository/interchange/MANIFEST,v
retrieving revision 2.37
retrieving revision 2.38
diff -u -r2.37 -r2.38
--- MANIFEST	22 May 2002 07:29:18 -0000	2.37
+++ MANIFEST	25 May 2002 13:27:58 -0000	2.38
@@ -930,6 +930,7 @@
 lib/Vend/Table/InMemory.pm
 lib/Vend/Table/LDAP.pm
 lib/Vend/Table/SDBM.pm
+lib/Vend/Table/Shadow.pm
 lib/Vend/Tags.pm
 lib/Vend/TextSearch.pm
 lib/Vend/Track.pm



2.41      +7 -2      interchange/lib/Vend/Config.pm


rev 2.41, prev_rev 2.40
Index: Config.pm
===================================================================
RCS file: /anon_cvs/repository/interchange/lib/Vend/Config.pm,v
retrieving revision 2.40
retrieving revision 2.41
diff -u -r2.40 -r2.41
--- Config.pm	5 Mar 2002 13:42:43 -0000	2.40
+++ Config.pm	25 May 2002 13:27:58 -0000	2.41
@@ -1,6 +1,6 @@
 # Vend::Config - Configure Interchange
 #
-# $Id: Config.pm,v 2.40 2002/03/05 13:42:43 kwalsh Exp $
+# $Id: Config.pm,v 2.41 2002/05/25 13:27:58 racke Exp $
 #
 # Copyright (C) 1996-2001 Red Hat, Inc. <interchange@redhat.com>
 #
@@ -44,7 +44,7 @@
 use Vend::Parse;
 use Vend::Util;
 
-$VERSION = substr(q$Revision: 2.40 $, 10);
+$VERSION = substr(q$Revision: 2.41 $, 10);
 
 my %CDname;
 
@@ -2799,6 +2799,11 @@
 					$d->{$p},
 				);
 			$d->{$p} = $val;
+		}
+		if ($p eq 'MAP') {
+			$d->{OrigClass} = $d->{Class};
+			$d->{Class} = 'SHADOW';
+			$d->{type} = 10;
 		}
 		$d->{HOT} = 1 if $d->{Class} eq 'MEMORY';
 	}



2.8       +9 -1      interchange/lib/Vend/Data.pm


rev 2.8, prev_rev 2.7
Index: Data.pm
===================================================================
RCS file: /anon_cvs/repository/interchange/lib/Vend/Data.pm,v
retrieving revision 2.7
retrieving revision 2.8
diff -u -r2.7 -r2.8
--- Data.pm	5 Feb 2002 01:33:11 -0000	2.7
+++ Data.pm	25 May 2002 13:27:58 -0000	2.8
@@ -1,6 +1,6 @@
 # Vend::Data - Interchange databases
 #
-# $Id: Data.pm,v 2.7 2002/02/05 01:33:11 mheins Exp $
+# $Id: Data.pm,v 2.8 2002/05/25 13:27:58 racke Exp $
 # 
 # Copyright (C) 1996-2001 Red Hat, Inc. <interchange@redhat.com>
 #
@@ -83,6 +83,7 @@
 		require Vend::Table::DB_File;
 	}
 	require Vend::Table::InMemory;
+	require Vend::Table::Shadow;
 }
 
 my ($Products, $Item_price);
@@ -599,6 +600,13 @@
 				/
 				},
 # END SQL
+		'SHADOW' => {
+				qw/
+					Extension			 shadow
+					RestrictedImport	 1
+					Class                Vend::Table::Shadow
+				/
+				},
 		'MEMORY' => {
 				qw/
 					Cacheable			 1



1.1                  interchange/lib/Vend/Table/Shadow.pm


rev 1.1, prev_rev 1.0
Index: Shadow.pm
===================================================================
# Vend::Table::Shadow - Access a virtual "Shadow" table
#
# $Id: Shadow.pm,v 1.1 2002/05/25 13:27:58 racke Exp $
#
# Copyright (C) 2002 Stefan Hornburg (Racke) <racke@linuxia.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA  02111-1307  USA.

package Vend::Table::Shadow;
$VERSION = substr(q$Revision: 1.1 $, 10);

# TODO
#
# Config.pm:
# - check MAP to avoid mapping the key

use strict;

use vars qw($CONFIG $TABLE $KEY $NAME $TYPE $OBJ);
($CONFIG, $TABLE, $KEY, $NAME, $TYPE, $OBJ) = (0 .. 5);

sub import_db {
	my($s) = @_;
	my $db = Vend::Data::import_database($s->[0], 1);
	return undef if ! $db;
	$Vend::Database{$s->[0]{name}} = $db;
	Vend::Data::update_productbase($s->[0]{name});
	return $db;
}

sub create {
	# create the real table we put the shadow around
	my ($class, $config, $columns, $tablename) = @_;
	my $obj;
	
	no strict 'refs';
	$obj = &{"Vend::Table::$config->{OrigClass}::create"}('',$config,$columns,$tablename);
	my $s = [$config, $tablename, undef, $columns, undef, $obj];
	bless $s, $class;
	
	return $s;
}

sub new {
	my ($class, $obj) = @_;
	bless [$obj], $class;
}

sub open_table {
	my ($class, $config, $tablename) = @_;
	my $obj;
	
	no strict 'refs';
	$obj = &{"Vend::Table::$config->{OrigClass}::open_table"}("Vend::Table::$config->{OrigClass}",$config,$tablename);
	my $s = [$config, $tablename, undef, undef, undef, $obj];
	bless $s, $class;
	
	return $s;
}

sub close_table {
	my $s = shift;
	$s->[$OBJ]->close_table();
}

sub columns {
	my ($s) = shift;
	$s = $s->import_db() if ! defined $s->[$OBJ];
	return $s->[$OBJ]->columns();
}

sub ref {
	return $_[0] if defined $_[0]->[$OBJ];
	return $_[0]->import_db();
}

sub record_exists {
	my ($s, $key) = @_;
	$s = $s->import_db() unless defined $s->[$OBJ];
	$s->[$OBJ]->record_exists($key);
}

sub each_nokey {
	my ($s, $qual) = @_;
	$s = $s->import_db() unless defined $s->[$OBJ];
	::logDebug('COLUMNS: ' . $s->columns());
	return $s->[$OBJ]->each_nokey($qual);
}

1;



2.30      +3 -1      interchange/scripts/interchange.PL


rev 2.30, prev_rev 2.29
Index: interchange.PL
===================================================================
RCS file: /anon_cvs/repository/interchange/scripts/interchange.PL,v
retrieving revision 2.29
retrieving revision 2.30
diff -u -r2.29 -r2.30
--- interchange.PL	20 May 2002 15:18:43 -0000	2.29
+++ interchange.PL	25 May 2002 13:27:58 -0000	2.30
@@ -50,7 +50,7 @@
 #
 # Interchange version 4.9.0
 #
-# $Id: interchange.PL,v 2.29 2002/05/20 15:18:43 racke Exp $
+# $Id: interchange.PL,v 2.30 2002/05/25 13:27:58 racke Exp $
 #
 # Copyright (C) 1996-2001 Red Hat, Inc. <interchange@redhat.com>
 #
@@ -192,6 +192,7 @@
 # SQL
 	$Global::DBI =
 # END SQL
+    $Global::Shadow = 
 	0;
 
 # SQL
@@ -253,6 +254,7 @@
 	$Global::Default_database = 'MEMORY'
 			unless defined $Global::Default_database;
 	require Vend::Table::InMemory;
+	require Vend::Table::Shadow;
 }