X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=lib%2FMaypole%2FView%2FTT.pm;h=4bd7c0ebb836af2acd0817aba039b1da8b58b7e1;hb=cdf684b24a154500e5c05a49be8b5c7bae6a08a8;hp=babd0f457a9260735ccd438eb88c5b2ce2c00837;hpb=d09e000fc977211b8bd1a77285a952421b60aa7a;p=maypole.git diff --git a/lib/Maypole/View/TT.pm b/lib/Maypole/View/TT.pm index babd0f4..4bd7c0e 100644 --- a/lib/Maypole/View/TT.pm +++ b/lib/Maypole/View/TT.pm @@ -1,4 +1,4 @@ -package Apache::MVC::View::TT; +package Maypole::View::TT; use Apache::Constants; use Lingua::EN::Inflect; use Template; @@ -11,8 +11,8 @@ sub new { bless {}, shift } # Not worth having sub _tt { my ($self, $r) = @_; - my $root = $r->{ar}->document_root . "/". $r->{ar}->location; - warn "Root was $root"; + # This bit sucks. + my $root = $r->{config}{template_root} || $r->get_template_root; Template->new({ INCLUDE_PATH => [ $root, ($r->model_class && File::Spec->catdir($root, $r->model_class->moniker)), @@ -34,7 +34,7 @@ sub _args { if ($class) { $args{classmetadata} = { name => $class, - columns => [ $class->columns ], + columns => [ $class->display_columns ], colnames => { $class->column_names }, related_accessors => [ $class->related($r) ], moniker => $class->moniker, @@ -47,7 +47,7 @@ sub _args { if (@{$r->objects || []} > 1) { $args{$r->model_class->plural_moniker} = $r->objects; } else { - ($args{$r->model_class->moniker}) = @{$r->objects}; + ($args{$r->model_class->moniker}) = @{$r->objects ||[]}; } } @@ -63,10 +63,8 @@ sub process { $template->process($r->template, { $self->_args($r) }, \$output) || return $self->error($r, $template->error); - $r->{ar}->content_type("text/html"); - $r->{ar}->headers_out->set("Content-Length" => length $output); - $r->{ar}->send_http_header; - $r->{ar}->print($output); + $r->{content_type} ||= "text/html"; + $r->{output} = $output; return 200; } @@ -74,8 +72,9 @@ sub error { my ($self, $r, $error) = @_; warn $error; if ($error =~ /not found$/) { return DECLINED } - $r->{ar}->send_http_header("text/plain"); - $r->{ar}->print($error); + $r->{content_type} = "text/plain"; + $r->{output} = $error; + $r->send_output; exit; }