| Jifty documentation | Contained in the Jifty distribution. |
Jifty::View::Mason::Request -View mason request
Subclass of HTML::Mason::Request which is customised for Jifty's use.
Doesn't send headers if this is a subrequest (according to the current Jifty::Request).
Actually runs the component; in case no headers have been sent after running the component, and we're supposed to send headers, sends them.
Append to the shared String::BufferStack stored in buffer in Jifty::Handler.
Jump through hoops necessary to keep buffer in Jifty::Handler lined up with Mason's internal buffer stack.
Jump through hoops necessary to keep buffer in Jifty::Handler lined up with Mason's internal buffer stack.
Calls redirect in Jifty::Web.
| Jifty documentation | Contained in the Jifty distribution. |
use strict; use warnings; package Jifty::View::Mason::Request; # Subclass for HTML::Mason::Request object $m
use HTML::Mason::Exceptions; use HTML::Mason::Request; use base qw(HTML::Mason::Request);
sub auto_send_headers { Jifty::View->auto_send_headers; }
sub exec { my $self = shift; my $retval; eval { $retval = $self->SUPER::exec(@_) }; if (my $err = $@) { $retval = isa_mason_exception($err, 'Abort') ? $err->aborted_value : isa_mason_exception($err, 'Decline') ? $err->declined_value : rethrow_exception $err; } return $retval; }
sub print { shift; Jifty->handler->buffer->append(@_); } *out = \&print;
sub comp { my $self = shift; my %mods; %mods = (%{shift()}, %mods) while ref($_[0]) eq 'HASH'; my @args; push @args, buffer => delete $mods{store} if $mods{store} and $mods{store} ne \($self->{request_buffer}); my $file = (ref $_[0] ? $_[0]{path} : $_[0]); Jifty->handler->buffer->push(@args, from => "Mason path $file", file => $file); my $wantarray = wantarray; my @result; if ($wantarray) { @result = $self->SUPER::comp(\%mods, @_); } elsif (defined $wantarray) { $result[0] = $self->SUPER::comp(\%mods, @_); } else { $self->SUPER::comp(\%mods, @_); } Jifty->handler->buffer->pop; return $wantarray ? @result : $result[0]; }
sub content { my $self = shift; Jifty->handler->buffer->push( private => 1, from => "Mason call to content" ); $self->SUPER::content; return Jifty->handler->buffer->pop; }
sub redirect { my $self = shift; my $url = shift; Jifty->web->redirect($url); } 1;