chiark
/
gitweb
/
~yarrgweb
/
ypp-sc-tools.db-live.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b83c36d
)
Pass $dbh down through the stack, for better lifetime
author
Ian Jackson
<ian@liberator.relativity.greenend.org.uk>
Sun, 16 Aug 2009 15:03:45 +0000
(16:03 +0100)
committer
Ian Jackson
<ian@liberator.relativity.greenend.org.uk>
Sun, 16 Aug 2009 15:03:45 +0000
(16:03 +0100)
yarrg/web/lookup
patch
|
blob
|
history
yarrg/web/qtextstring
patch
|
blob
|
history
yarrg/web/qtextstringcheck
patch
|
blob
|
history
yarrg/web/query_age
patch
|
blob
|
history
yarrg/web/query_commod
patch
|
blob
|
history
yarrg/web/query_route
patch
|
blob
|
history
yarrg/web/routetrade
patch
|
blob
|
history
diff --git
a/yarrg/web/lookup
b/yarrg/web/lookup
index 1b85ecc8b9d06b9dc5ba96b14b63e4cac99501c0..f194fc5d56d2cb3f4a6a2e955dd0b84c3493cfc2 100755
(executable)
--- a/
yarrg/web/lookup
+++ b/
yarrg/web/lookup
@@
-160,7
+160,8
@@
foreach my $var (@vars) {
die if $styles{Query} =~ m/[^a-z]/;
die if $styles{Query} =~ m/[^a-z]/;
-dbw_connect($styles{Ocean});
+my $mydbh;
+my $dbh= ($mydbh= dbw_connect($styles{Ocean}));
my $results_head_done=0;
my $someresults= sub {
my $results_head_done=0;
my $someresults= sub {
@@
-176,7
+177,8
@@
$debug => 0
<hr>
<hr>
-<& "query_$styles{Query}", %baseqf, %queryqf, %styles, quri => $quri,
+<& "query_$styles{Query}", %baseqf, %queryqf, %styles,
+ quri => $quri, dbh => $dbh,
someresults => $someresults,
emsgokorprint => sub {
my ($emsg) = @_;
someresults => $someresults,
emsgokorprint => sub {
my ($emsg) = @_;
@@
-215,3
+217,8
@@
use HTML::Entities;
use URI::Escape;
</%init>
use URI::Escape;
</%init>
+<%cleanup>
+
+$mydbh->rollback() if $mydbh;
+
+</%cleanup>
diff --git
a/yarrg/web/qtextstring
b/yarrg/web/qtextstring
index 3b0bd6b72e65b5f942ff1eff70b0786d9901c903..16aa372bd6794caad89992d6d7b2f2a976d519c2 100644
(file)
--- a/
yarrg/web/qtextstring
+++ b/
yarrg/web/qtextstring
@@
-36,10
+36,11
@@
</%doc>
<%args>
</%doc>
<%args>
+$qa => $m->caller_args(1)->{'qa'}
+$dbh
$thingstring
$emsgstore
$perresult
$thingstring
$emsgstore
$perresult
-$qa => $m->caller_args(1)->{'qa'}
</%args>
<%perl>
my $stringval= $qa->{$thingstring};
</%args>
<%perl>
my $stringval= $qa->{$thingstring};
diff --git
a/yarrg/web/qtextstringcheck
b/yarrg/web/qtextstringcheck
index 5ef8971f644b63991af5d6eb5379be7fec1da596..b2c101390589b01daf00d858c60f9d205d05ce83 100755
(executable)
--- a/
yarrg/web/qtextstringcheck
+++ b/
yarrg/web/qtextstringcheck
@@
-43,6
+43,7
@@
$format
$ctype => undef
$string
$what
$ctype => undef
$string
$what
+$dbh => undef
</%args>
<%flags>
</%args>
<%flags>
@@
-58,7
+59,8
@@
use CommodsWeb;
die if $what =~ m/[^a-z]/;
my $chk= $m->fetch_comp("check_${what}");
die if $what =~ m/[^a-z]/;
my $chk= $m->fetch_comp("check_${what}");
-my $dbh= dbw_connect($ocean);
+my $mydbh;
+$dbh ||= ($mydbh= dbw_connect($ocean));
my $sqlstmt= $chk->scall_method("sqlstmt");
my $sth= $dbh->prepare($sqlstmt);
my $sqlstmt= $chk->scall_method("sqlstmt");
my $sth= $dbh->prepare($sqlstmt);
@@
-119,7
+121,7
@@
if ($format =~ /dump/) {
print Dumper($emsg, $canontext, \@results);
}
print Dumper($emsg, $canontext, \@results);
}
-$
dbh->rollback()
;
+$
mydbh->rollback() if $mydbh
;
return $emsg,
$canontext,
return $emsg,
$canontext,
diff --git
a/yarrg/web/query_age
b/yarrg/web/query_age
index 922e29f0c90031b97e1c485bb6fcb456946f8018..77d750c8c95ec2c0386b79f785111df215851e0b 100644
(file)
--- a/
yarrg/web/query_age
+++ b/
yarrg/web/query_age
@@
-33,6
+33,12
@@
</%doc>
</%doc>
+
+<%args>
+$quri
+$dbh
+</%args>
+
<%once>
my $meta_prettyprint_age= sub {
my ($age,$floor,$plus) = @_;
<%once>
my $meta_prettyprint_age= sub {
my ($age,$floor,$plus) = @_;
@@
-56,7
+62,6
@@
eval '
</%once>
<%perl>
</%once>
<%perl>
-
my $now= time;
my $row;
my $now= time;
my $row;
@@
-96,10
+101,8
@@
Time since this page loaded:
<span id="daid_loaded">(not known; times above not updating)</span>
<form action="lookup" method="get">
<span id="daid_loaded">(not known; times above not updating)</span>
<form action="lookup" method="get">
-% foreach my $a (keys %ARGS) {
-<input type="hidden" name="<% $a |h %>" value="<% $ARGS{$a} |h %>">
-% }
<input type=submit name=submit value="Reload">
<input type=submit name=submit value="Reload">
+<& "lookup:formhidden", ours => sub { 0; } &>
</form>
<&| script &>
</form>
<&| script &>
@@
-128,8
+131,4
@@
Time since this page loaded:
<%init>
use POSIX;
use CommodsWeb;
<%init>
use POSIX;
use CommodsWeb;
-my $dbh= dbw_connect('Midnight');
</%init>
</%init>
-<%cleanup>
-$dbh->rollback();
-</%cleanup>
diff --git
a/yarrg/web/query_commod
b/yarrg/web/query_commod
index eddc0975d05f067358c6835a81710d97f8039b8d..9cb14ca6870e70abf887b518f2e9698313d67158 100644
(file)
--- a/
yarrg/web/query_commod
+++ b/
yarrg/web/query_commod
@@
-35,6
+35,7
@@
</%doc>
<%args>
$quri
</%doc>
<%args>
$quri
+$dbh
$commodstring => '';
$someresults
$emsgokorprint
$commodstring => '';
$someresults
$emsgokorprint
@@
-56,7
+57,8
@@
Enter commodity (abbreviations are OK):<br>
<form action="<% $quri->() |h %>" method="get">
<form action="<% $quri->() |h %>" method="get">
-<&| qtextstring, qa => $qa, thingstring => 'commodstring', emsgstore => \$emsg,
+<&| qtextstring, qa => $qa, dbh => $dbh,
+ thingstring => 'commodstring', emsgstore => \$emsg,
perresult => sub { ($commodname,$commodid)= @_; }
&>
size=80
perresult => sub { ($commodname,$commodid)= @_; }
&>
size=80
diff --git
a/yarrg/web/query_route
b/yarrg/web/query_route
index 66dee1dd08135de011871b15d71d963f7db235af..e9e358a433bc928b325a773651441b9ee25971d4 100644
(file)
--- a/
yarrg/web/query_route
+++ b/
yarrg/web/query_route
@@
-35,6
+35,7
@@
</%doc>
<%args>
$quri
</%doc>
<%args>
$quri
+$dbh
$routestring => '';
$someresults
$emsgokorprint
$routestring => '';
$someresults
$emsgokorprint
@@
-59,7
+60,8
@@
Enter route (islands, or archipelagoes, separated by |s or commas;
<form action="<% $quri->() |h %>" method="get">
<form action="<% $quri->() |h %>" method="get">
-<&| qtextstring, qa => $qa, thingstring => 'routestring', emsgstore => \$emsg,
+<&| qtextstring, qa => $qa, dbh => $dbh,
+ thingstring => 'routestring', emsgstore => \$emsg,
perresult => sub {
my ($canonname, $island, $arch) = @_;
push @islandids, $island;
perresult => sub {
my ($canonname, $island, $arch) = @_;
push @islandids, $island;
@@
-90,8
+92,6
@@
my $optionlistmap= sub {
return $out;
};
return $out;
};
-my $dbh= dbw_connect($qa->{Ocean});
-
$sth= $dbh->prepare("SELECT DISTINCT archipelago FROM islands
ORDER BY archipelago;");
$sth->execute();
$sth= $dbh->prepare("SELECT DISTINCT archipelago FROM islands
ORDER BY archipelago;");
$sth->execute();
@@
-120,8
+120,6
@@
foreach my $arch (keys %islandlistdata) {
$optionlistmap->($islandlistdata{$arch}, '');
}
$optionlistmap->($islandlistdata{$arch}, '');
}
-$dbh->rollback();
-
</%perl>
<&| script &>
</%perl>
<&| script &>
@@
-206,5
+204,8
@@
for my $dd (0..$qa->{Dropdowns}-1) {
% if (@islandids) {
% $someresults->();
% if (@islandids) {
% $someresults->();
-<& routetrade, islandids => \@islandids, archipelagoes => \@archipelagoes &>
+<& routetrade,
+ dbh => $dbh,
+ islandids => \@islandids,
+ archipelagoes => \@archipelagoes &>
% }
% }
diff --git
a/yarrg/web/routetrade
b/yarrg/web/routetrade
index 4475d27197915154c8cc4204556c10259dd355b2..1c5a3e49db2b184ac019b4a8177cb8838df59040 100644
(file)
--- a/
yarrg/web/routetrade
+++ b/
yarrg/web/routetrade
@@
-1,4
+1,5
@@
<%args>
<%args>
+$dbh
@islandids
@archipelagoes
</%args>
@islandids
@archipelagoes
</%args>
@@
-22,5
+23,4
@@
Route is as follows:
<%init>
use CommodsWeb;
<%init>
use CommodsWeb;
-my $dbh= dbw_connect('Midnight');
</%init>
</%init>