adjust call to Persistance to work with new abstraction.

This commit is contained in:
kestes%staff.mail.com 2000-08-24 14:52:11 +00:00
Родитель ff9c647a77
Коммит 99ee59ceb8
4 изменённых файлов: 41 добавлений и 64 удалений

Просмотреть файл

@ -2,9 +2,9 @@
# -*- Mode: perl; indent-tabs-mode: nil -*-
#
# $Revision: 1.1 $
# $Date: 2000-06-22 04:10:42 $
# $Author: mcafee%netscape.com $
# $Revision: 1.2 $
# $Date: 2000-08-24 14:47:09 $
# $Author: kestes%staff.mail.com $
# $Source: /home/jrmuizel/cvs-mirror/mozilla/webtools/tinderbox2/src/bin/addnote.cgi,v $
# $Name: $
@ -197,8 +197,7 @@ sub save_note {
main::mkdir_R(dirname($update_file));
Persistence::save_structure(
[$record],
['record'],
$record,
$tmp_file,
);

Просмотреть файл

@ -6,9 +6,9 @@
# as a Dump of the $DATABASE reference.
# $Revision: 1.1 $
# $Date: 2000-06-22 04:16:47 $
# $Author: mcafee%netscape.com $
# $Revision: 1.2 $
# $Date: 2000-08-24 14:52:11 $
# $Author: kestes%staff.mail.com $
# $Source: /home/jrmuizel/cvs-mirror/mozilla/webtools/tinderbox2/src/lib/TinderDB/BasicTxtDB.pm,v $
# $Name: $
@ -45,7 +45,7 @@ use FileStructure;
use Persistence;
$VERSION = ( qw $Revision: 1.1 $ )[1];
$VERSION = ( qw $Revision: 1.2 $ )[1];
# To help preserve the database in the event of a serious system
@ -175,32 +175,26 @@ sub loadtree_db {
"to $filename: $!\n");
}
{
# try something out here, this could eventually implement
# load_structure in Persistence::Dumper.pm
my $namespace = ref($self);
my $str = (
" ( \$$namespace"."::DATABASE{'$tree'}, ".
" \$$namespace"."::METADATA{'$tree'}, ) ".
'= @{ $r } ;'
);
main::null();
main::null();
main::null();
main::null();
}
# if we are running for the first time there may not be any data for
# us to read.
(-r $filename) || return ;
require($filename) ||
die("Could not eval filename: '$filename': $!\n");
my ($r) = Persistence::load_structure($filename);
# Put the data into the correct namespace.
# If you can find a way to do this without the eval please help. The
# perl parser evaluates all my attempts to mean something else.
my $namespace = ref($self);
my $str = (
" ( \$$namespace"."::DATABASE{'$tree'}, ".
" \$$namespace"."::METADATA{'$tree'}, ) ".
'= @{ $r } ;'
);
eval $str;
# ignore unlink errors, cleaning up the directory is not important.
(scalar(@sorted_files)) &&
@ -228,16 +222,12 @@ sub savetree_db {
my ($name_db) = "${name_space}::DATABASE";
my ($name_meta) = "${name_space}::METADATA";
Persistence::save_structure(
[
$ { $name_db }{$tree},
$ { $name_meta }{$tree}
],
[
"\$${name_space}::DATABASE{$tree}",
"\$${name_space}::METADATA{$tree}"
],
$data_file
);
[
$ { $name_db }{$tree},
$ { $name_meta }{$tree}
],
$data_file
);
return ;
}

Просмотреть файл

@ -73,7 +73,7 @@ use Utils;
use HTMLPopUp;
use TinderDB::BasicTxtDB;
$VERSION = ( qw $Revision: 1.2 $ )[1];
$VERSION = ( qw $Revision: 1.3 $ )[1];
@ISA = qw(TinderDB::BasicTxtDB);
@ -142,9 +142,10 @@ sub apply_db_updates {
# This require will set a variable called $record with all
# the info from this build update.
require ("$dirname/$update_file") ||
die("Could not eval filename: ".
"'$dirname/$filename': $!\n");
my ($record) = Persistence::load_structure("$dirname/$update_file");
($record) ||
die("Error reading Notice update file '$dirname/$update_file'.\n");
my $time = $record->{'time'};
my $mailaddr = $record->{'mailaddr'};

Просмотреть файл

@ -6,8 +6,8 @@
# gettree_header(), ).
# $Revision: 1.2 $
# $Date: 2000-08-11 00:20:31 $
# $Revision: 1.3 $
# $Date: 2000-08-24 14:50:19 $
# $Author: kestes%staff.mail.com $
# $Source: /home/jrmuizel/cvs-mirror/mozilla/webtools/tinderbox2/src/lib/TinderHeader/BasicTxtHeader.pm,v $
# $Name: $
@ -46,7 +46,7 @@ package TinderHeader::BasicTxtHeader;
use FileStructure;
use Persistence;
$VERSION = ( qw $Revision: 1.2 $ )[1];
$VERSION = ( qw $Revision: 1.3 $ )[1];
sub new {
@ -86,21 +86,13 @@ sub savetree_header {
my ($filename) = $self->db_file($tree);
my ($name_space) = ref($self);
Persistence::save_structure(
[
$value,
],
[
"\$".$name_space."{'$tree'}",
],
$filename);
Persistence::save_structure($value, $filename);
return ;
}
# return the "$value" which is defined by evaling the file
# FileStructure::get_filename($tree, ref($self)).
# return the "$value" which was saved into the file
sub gettree_header {
my ($self, $tree) = @_;
@ -110,12 +102,7 @@ sub gettree_header {
(-r $filename) ||
return ;
require($filename) ||
die("Could not eval filename: '$filename': $!\n");
my ($variable) = "\$".$name_space."{'$tree'}";
my ($value);
eval "\$value = $variable";
my ($value) = Persistence::load_structure($filename);
return $value
}