[Jifty-commit] r6304 - in jifty/trunk: lib/Jifty/View/Mason plugins.old/EditInPlace/lib/Jifty/Plugin

Jifty commits jifty-commit at lists.jifty.org
Wed Feb 4 15:48:02 EST 2009


Author: alexmv
Date: Wed Feb  4 15:48:02 2009
New Revision: 6304

Added:
   jifty/trunk/lib/Jifty/View/Mason/Request.pm
Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/lib/Jifty/View/Mason/Handler.pm
   jifty/trunk/plugins.old/EditInPlace/lib/Jifty/Plugin/EditInPlace.pm

Log:
 r41855 at kohr-ah:  chmrr | 2009-02-04 15:46:02 -0500
  * Split out Jifty::View::Mason::Request (renamed from HTML::Mason::Request::Jifty)


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	Wed Feb  4 15:48:02 2009
@@ -21,6 +21,7 @@
 use HTML::Mason::Exceptions;
 use HTML::Mason::FakeApache;
 use Encode qw();
+use Jifty::View::Mason::Request;
 
 use Class::Container;
 use base qw(Jifty::View Class::Container);
@@ -45,7 +46,7 @@
 
 Takes a number of key-value parameters; see L<HTML::Mason::Params>.
 Defaults the C<out_method> to appending to L<Jifty::Handler/buffer>
-and the C<request_class> to L<HTML::Mason::Request::Jifty> (below).
+and the C<request_class> to L<Jifty::View::Mason::Request> (below).
 Finally, adds C<h> and C<u> escapes, which map to L</escape_uri> and
 L<escape_utf8> respectively.
 
@@ -55,7 +56,7 @@
     my $package = shift;
 
     my %p = @_ || $package->config;
-    my $self = $package->SUPER::new( request_class => 'HTML::Mason::Request::Jifty',
+    my $self = $package->SUPER::new( request_class => 'Jifty::View::Mason::Request',
                                      out_method => sub {Carp::cluck("Mason output skipped Jifty's output stack!") if grep {defined and length} @_},
                                      %p );
     $self->interp->compiler->add_allowed_globals('$r');
@@ -239,109 +240,5 @@
     return %{Jifty->web->request->arguments}, %{Jifty->web->request->template_arguments || {}};
 }
 
-###########################################################
-package HTML::Mason::Request::Jifty;
-# Subclass for HTML::Mason::Request object $m
-
-=head1 HTML::Mason::Request::Jifty
-
-Subclass of L<HTML::Mason::Request> which is customised for Jifty's use.
-
-=cut
-
-use HTML::Mason::Exceptions;
-use HTML::Mason::Request;
-use base qw(HTML::Mason::Request);
-
-=head2 auto_send_headers
-
-Doesn't send headers if this is a subrequest (according to the current
-L<Jifty::Request>).
-
-=cut
-
-sub auto_send_headers {
-    Jifty::View->auto_send_headers;
-}
-
-=head2 exec
-
-Actually runs the component; in case no headers have been sent after
-running the component, and we're supposed to send headers, sends them.
-
-=cut
-
-sub exec
-{
-    my $self = shift;
-    my $r = Jifty->handler->apache;
-    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;
-    }
-
-    # On a success code, send headers if they have not been sent and
-    # if we are the top-level request. Since the out_method sends
-    # headers, this will typically only apply after $m->abort.
-    if ($self->auto_send_headers
-        and not $r->http_header_sent
-        and (!$retval or $retval==200)) {
-        Jifty->handler->send_http_header;
-    }
-}
-
-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});
-    Jifty->handler->buffer->push(@args, from => "Mason path ".(ref $_[0] ? $_[0]{path} : $_[0]));
-
-    my $wantarray = wantarray;
-    my @result;
-    eval {
-        if ($wantarray) {
-            @result = $self->SUPER::comp(\%mods, @_);
-        } elsif (defined $wantarray) {
-            $result[0] = $self->SUPER::comp(\%mods, @_);
-        } else {
-            $self->SUPER::comp(\%mods, @_);
-        }
-    };
-    my $error = $@;
-
-    Jifty->handler->buffer->pop;
-
-    rethrow_exception $error if $error;
-    return $wantarray ? @result : $result[0];    
-}
-
-=head2 redirect
-
-Calls L<Jifty::Web/redirect>.
-
-=cut
-
-sub redirect {
-    my $self = shift;
-    my $url = shift;
-
-    Jifty->web->redirect($url);
-}
-
 1;
+

Added: jifty/trunk/lib/Jifty/View/Mason/Request.pm
==============================================================================
--- (empty file)
+++ jifty/trunk/lib/Jifty/View/Mason/Request.pm	Wed Feb  4 15:48:02 2009
@@ -0,0 +1,108 @@
+use strict;
+use warnings;
+
+package Jifty::View::Mason::Request;
+# Subclass for HTML::Mason::Request object $m
+
+=head1 Jifty::View::Mason::Request
+
+Subclass of L<HTML::Mason::Request> which is customised for Jifty's use.
+
+=cut
+
+use HTML::Mason::Exceptions;
+use HTML::Mason::Request;
+use base qw(HTML::Mason::Request);
+
+=head2 auto_send_headers
+
+Doesn't send headers if this is a subrequest (according to the current
+L<Jifty::Request>).
+
+=cut
+
+sub auto_send_headers {
+    Jifty::View->auto_send_headers;
+}
+
+=head2 exec
+
+Actually runs the component; in case no headers have been sent after
+running the component, and we're supposed to send headers, sends them.
+
+=cut
+
+sub exec
+{
+    my $self = shift;
+    my $r = Jifty->handler->apache;
+    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;
+    }
+
+    # On a success code, send headers if they have not been sent and
+    # if we are the top-level request. Since the out_method sends
+    # headers, this will typically only apply after $m->abort.
+    if ($self->auto_send_headers
+        and not $r->http_header_sent
+        and (!$retval or $retval==200)) {
+        Jifty->handler->send_http_header;
+    }
+}
+
+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});
+    Jifty->handler->buffer->push(@args, from => "Mason path ".(ref $_[0] ? $_[0]{path} : $_[0]));
+
+    my $wantarray = wantarray;
+    my @result;
+    eval {
+        if ($wantarray) {
+            @result = $self->SUPER::comp(\%mods, @_);
+        } elsif (defined $wantarray) {
+            $result[0] = $self->SUPER::comp(\%mods, @_);
+        } else {
+            $self->SUPER::comp(\%mods, @_);
+        }
+    };
+    my $error = $@;
+
+    Jifty->handler->buffer->pop;
+
+    rethrow_exception $error if $error;
+    return $wantarray ? @result : $result[0];    
+}
+
+=head2 redirect
+
+Calls L<Jifty::Web/redirect>.
+
+=cut
+
+sub redirect {
+    my $self = shift;
+    my $url = shift;
+
+    Jifty->web->redirect($url);
+}
+
+1;

Modified: jifty/trunk/plugins.old/EditInPlace/lib/Jifty/Plugin/EditInPlace.pm
==============================================================================
--- jifty/trunk/plugins.old/EditInPlace/lib/Jifty/Plugin/EditInPlace.pm	(original)
+++ jifty/trunk/plugins.old/EditInPlace/lib/Jifty/Plugin/EditInPlace.pm	Wed Feb  4 15:48:02 2009
@@ -5,7 +5,7 @@
 use base qw/Jifty::Plugin/;
 
 
-package HTML::Mason::Request::Jifty;
+package Jifty::View::Mason::Request;
 
 =head2 fetch_comp
 


More information about the Jifty-commit mailing list