[Jifty-commit] r851 - in jifty/trunk: lib/Jifty lib/Jifty/Web
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Wed Apr 12 22:16:31 EDT 2006
Author: jesse
Date: Wed Apr 12 22:16:30 2006
New Revision: 851
Modified:
jifty/trunk/ (props changed)
jifty/trunk/lib/Jifty/Dispatcher.pm
jifty/trunk/lib/Jifty/Request.pm
jifty/trunk/lib/Jifty/Web/PageRegion.pm
Log:
r11601 at hualien: jesse | 2006-04-12 22:15:47 -0400
* A little bit of work to make PageRegion calls a little bit lighter.
Modified: jifty/trunk/lib/Jifty/Dispatcher.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Dispatcher.pm (original)
+++ jifty/trunk/lib/Jifty/Dispatcher.pm Wed Apr 12 22:16:30 2006
@@ -407,7 +407,6 @@
sub handle_request {
my $self = shift;
-
local $Dispatcher = $self->new();
# XXX TODO: refactor this out somehow?
Modified: jifty/trunk/lib/Jifty/Request.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Request.pm (original)
+++ jifty/trunk/lib/Jifty/Request.pm Wed Apr 12 22:16:30 2006
@@ -591,6 +591,18 @@
return $action;
}
+
+=head2 clear_actions
+
+Removes all actions from this request
+
+=cut
+
+sub clear_actions {
+ my $self = shift;
+ $self->{'actions'} = {};
+}
+
=head2 remove_action MONIKER
Removes an action with the given moniker.
Modified: jifty/trunk/lib/Jifty/Web/PageRegion.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web/PageRegion.pm (original)
+++ jifty/trunk/lib/Jifty/Web/PageRegion.pm Wed Apr 12 22:16:30 2006
@@ -232,15 +232,18 @@
sub render {
my $self = shift;
- my %arguments = %{$self->arguments};
+ my %arguments = %{ $self->arguments };
# undef arguments cause warnings. We hatesses the warnings, we do.
defined $arguments{$_} or delete $arguments{$_} for keys %arguments;
my $result = "";
# Map out the arguments
- for (keys %arguments) {
- my ($key, $value) = Jifty::Request::Mapper->map(destination => $_, source => $arguments{$_});
+ for ( keys %arguments ) {
+ my ( $key, $value ) = Jifty::Request::Mapper->map(
+ destination => $_,
+ source => $arguments{$_}
+ );
next unless $key ne $_;
delete $arguments{$_};
$arguments{$key} = $value;
@@ -248,51 +251,55 @@
# We need to tell the browser this is a region and
# what its default arguments are as well as the path of the "fragment".
-
- # We do this by passing in a snippet of javascript which encodes this
+
+ # We do this by passing in a snippet of javascript which encodes this
# information.
- # Alex is sad about: Anything which is replaced _must_ start life as a fragment.
- # We don't have a good answer for this yet.
+# Alex is sad about: Anything which is replaced _must_ start life as a fragment.
+# We don't have a good answer for this yet.
- # We only render the region wrapper if we're asked to (which is true by default)
- if ($self->region_wrapper) {
- $result .= qq|<script type="text/javascript">\n|;
- $result .= qq|new Region('|. $self->qualified_name . qq|',|;
- $result .= Jifty::JSON::objToJson(\%arguments, {singlequote => 1}) . qq|,|;
- $result .= qq|'| . $self->path . qq|',|;
- $result .= $self->parent ? qq|'| . $self->parent->qualified_name . qq|'| : q|null|;
- $result .= qq|);\n|;
- $result .= qq|</script>|;
- $result .= qq|<div id="region-| . $self->qualified_name . qq|">|;
+# We only render the region wrapper if we're asked to (which is true by default)
+ if ( $self->region_wrapper ) {
+ $result .= qq|<script type="text/javascript">\n|
+ . qq|new Region('| . $self->qualified_name . qq|',|
+ . Jifty::JSON::objToJson( \%arguments, { singlequote => 1 } ) . qq|,|
+ . qq|'| . $self->path . qq|',|
+ . ( $self->parent ? qq|'| . $self->parent->qualified_name . qq|'| : q|null|)
+ . qq|);\n|
+ . qq|</script>|
+ . qq|<div id="region-| . $self->qualified_name . qq|">|;
}
# Merge in defaults
- %arguments = (%{ Jifty->web->request->arguments }, region => $self, %arguments);
+ %arguments = ( %{ Jifty->web->request->arguments },
+ region => $self,
+ %arguments );
# Make a fake request and throw it at the dispatcher
my $subrequest = Jifty::Request->new;
- $subrequest->from_webform( %arguments );
+ $subrequest->from_webform(%arguments);
$subrequest->path( $self->path );
+
# Remove all of the actions
- $subrequest->remove_action( $_->moniker ) for $subrequest->actions;
- $subrequest->is_subrequest( 1 );
+ $subrequest->clear_actions;
+ $subrequest->is_subrequest(1);
local Jifty->web->{request} = $subrequest;
- # While we're inside this region, # have Mason to tack its response
+ # While we're inside this region, # have Mason to tack its response
# onto a variable and not send headers when it does so
-
+
# XXX TODO: this internals diving is icky
-
+
my $region_content = '';
- Jifty->handler->mason->interp->out_method( \$region_content);
+ Jifty->handler->mason->interp->out_method( \$region_content );
+
# Call into the dispatcher
- eval { Jifty->dispatcher->handle_request};
+ Jifty->dispatcher->handle_request;
$result .= $region_content;
- $result .= qq|</div>| if ($self->region_wrapper);
+ $result .= qq|</div>| if ( $self->region_wrapper );
#XXX TODO: There's gotta be a better way to localize it
- Jifty->handler->mason->interp->out_method( \&Jifty::View::Mason::Handler::out_method);
+ Jifty->handler->mason->interp->out_method( \&Jifty::View::Mason::Handler::out_method );
return $result;
}
More information about the Jifty-commit
mailing list