--- Webpacus/lib/Webpacus/Model/WebPAC.pm 2006/01/21 23:27:05 377
+++ Webpacus/lib/Webpacus/Model/WebPAC.pm 2006/01/21 23:27:16 378
@@ -6,14 +6,12 @@
use base qw/
Catalyst::Model
/;
-use Data::Dumper;
use WebPAC::Store 0.08;
-use WebPAC::Output::TT 0.07;
use WebPAC::Search::Estraier 0.05;
use File::Slurp;
-use Time::HiRes;
+use Time::HiRes qw/time/;
use Encode qw/encode decode from_to/;
-use Data::HTMLDumper;
+use Data::Dumper;
=head1 NAME
@@ -94,25 +92,6 @@
database => $est_cfg->{database},
);
- $self->{out} = new WebPAC::Output::TT(
- include_path => $template_path,
- filters => {
- dump_html => sub {
- return unless (@_);
- my $out;
- my $i = 1;
- foreach my $v (@_) {
- $out .= qq{
} .
- Data::HTMLDumper->Dump([ $v ],[ "v$i" ]) .
- qq{
};
- $i++;
- }
- $out =~ s!/]*>!!gis if ($out);
- return $out;
- }
- },
- );
-
# default template from config.yaml
$self->{template} ||= $c->config->{webpac}->{template};
@@ -123,6 +102,8 @@
$self->{databases} = $c->config->{databases} || $log->error("can't find databases in config");
+ $self->{model_record} = $c->comp('Model::Record') or $log->error("can't find Model::Record");
+
return $self;
}
@@ -148,6 +129,8 @@
sub search {
my $self = shift;
+ my $search_start_t = time();
+
my $args = {@_};
my $log = $self->{log};
@@ -188,7 +171,7 @@
my $hits = $#results + 1;
- $log->debug( sprintf("search took %.2fs and returned $hits hits.", $times->{est}) );
+ $log->debug( sprintf("search took %.6fs and returned $hits hits.", $times->{est}) );
# just return results?
return @results unless ($args->{'template'});
@@ -225,12 +208,18 @@
$t = time();
- my $html = $self->{out}->apply(
- template => $template_filename,
- data => $ds,
- record_uri => "${database}/${prefix}/${id}",
- config => $self->{databases}->{$database},
- );
+ my $html = '[no output]';
+
+ if ($self->{model_record}) {
+ $html = $self->{model_record}->apply(
+ template => $template_filename,
+ data => $ds,
+ record_uri => "${database}/${prefix}/${id}",
+ config => $self->{databases}->{$database},
+ );
+ } else {
+ $log->warn("skipped apply");
+ }
$times->{out} += time() - $t;
@@ -245,8 +234,8 @@
#$log->debug( '@html_results = ' . Dumper( \@html_results ) );
$log->debug( sprintf(
- "time spent: db = %.2f, out = %.2f",
- $times->{db}, $times->{out},
+ "duration breakdown: store %.6fs, apply %.6fs, total: %.6fs",
+ $times->{db}, $times->{out}, time() - $search_start_t,
) );
return \@html_results;
@@ -290,7 +279,7 @@
return;
}
- my $html = $self->{out}->apply(
+ my $html = $self->{model_record}->apply(
template => $args->{template},
data => $ds,
record_uri => $args->{record_uri},