[Jifty-commit] r3348 - in jifty/trunk/lib/Jifty: View/Mason

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Mon Jun 4 14:58:48 EDT 2007


Author: clkao
Date: Mon Jun  4 14:58:46 2007
New Revision: 3348

Modified:
   jifty/trunk/lib/Jifty/View/Mason/Handler.pm
   jifty/trunk/lib/Jifty/Web/PageRegion.pm

Log:
Move methods unrelated to mason to Jifty::View.

Modified: jifty/trunk/lib/Jifty/View/Mason/Handler.pm
==============================================================================
--- jifty/trunk/lib/Jifty/View/Mason/Handler.pm	(original)
+++ jifty/trunk/lib/Jifty/View/Mason/Handler.pm	Mon Jun  4 14:58:46 2007
@@ -23,7 +23,7 @@
 use Encode qw();
 
 use Class::Container;
-use base qw(Class::Container);
+use base qw(Jifty::View Class::Container);
 
 use HTML::Mason::MethodMaker
     ( read_write => [ qw( interp ) ] );
@@ -56,7 +56,7 @@
 
     my %p = @_ || $package->config;
     my $self = $package->SUPER::new( request_class => 'HTML::Mason::Request::Jifty',
-                                     out_method => \&out_method,
+                                     out_method => $package->can('out_method'),
                                      %p );
     $self->interp->compiler->add_allowed_globals('$r');
     $self->interp->set_escape( h => \&escape_utf8 );
@@ -117,37 +117,6 @@
     return %config;
 }
 
-=head2 out_method
-
-The default output method.  Sets the content-type to C<text/html;
-charset=utf-8> unless a content type has already been set, and then
-sends a header if need be.
-
-=cut
-
-sub out_method {
-    my $m = HTML::Mason::Request->instance;
-    my $r = Jifty->handler->apache;
-
-    $r->content_type || $r->content_type('text/html; charset=utf-8'); # Set up a default
-
-    unless ( $r->http_header_sent or not $m->auto_send_headers ) {
-        $r->send_http_header();
-    }
-
-    # We could perhaps install a new, faster out_method here that
-    # wouldn't have to keep checking whether headers have been
-    # sent and what the $r->method is.  That would require
-    # additions to the Request interface, though.
-    binmode *STDOUT;
-    if ( my ($enc) = $r->content_type =~ /charset=([\w-]+)$/ ) {
-        print STDOUT map Encode::encode($enc, $_), grep {defined} @_;
-    } else {
-        print STDOUT grep {defined} @_;
-    }
-}
-
-
 =head2 escape_utf8 SCALARREF
 
 Does a css-busting but minimalist escaping of whatever html you're passing in.
@@ -280,7 +249,7 @@
 =cut
 
 sub auto_send_headers {
-    return not Jifty->web->request->is_subrequest;
+    Jifty::View->auto_send_headers;
 }
 
 =head2 exec

Modified: jifty/trunk/lib/Jifty/Web/PageRegion.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web/PageRegion.pm	(original)
+++ jifty/trunk/lib/Jifty/Web/PageRegion.pm	Mon Jun  4 14:58:46 2007
@@ -298,7 +298,7 @@
 sub render_as_subrequest {
     my ($self, $out_method, $arguments, $enable_actions) = @_;
 
-    my $orig_out = Jifty->handler->mason->interp->out_method || \&Jifty::View::Mason::Handler::out_method;
+    my $orig_out = Jifty->handler->mason->interp->out_method || Jifty::View->can('out_method');
 
     Jifty->handler->mason->interp->out_method($out_method);
 


More information about the Jifty-commit mailing list