[Jifty-commit] r5613 - in jifty/trunk: lib/Jifty lib/Jifty/Subs
Jifty commits
jifty-commit at lists.jifty.org
Tue Jul 29 19:00:07 EDT 2008
Author: alexmv
Date: Tue Jul 29 19:00:01 2008
New Revision: 5613
Modified:
jifty/trunk/ (props changed)
jifty/trunk/lib/Jifty/Subs.pm
jifty/trunk/lib/Jifty/Subs/Render.pm
Log:
r34940 at kohr-ah: chmrr | 2008-07-29 18:59:20 -0400
* Multiple regions can be sub'd to the same channel
Modified: jifty/trunk/lib/Jifty/Subs.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Subs.pm (original)
+++ jifty/trunk/lib/Jifty/Subs.pm Tue Jul 29 19:00:01 2008
@@ -73,6 +73,7 @@
my $event_class = Jifty->app_class("Event", $args->{class});
my $queries = $args->{queries} || [];
+ my $region = $args->{region};
my $channel = $event_class->encode_queries(@$queries);
# The ->modify here is calling into the callback sub{...} with
@@ -92,7 +93,7 @@
# including the frament, region, argument and ajax updating mode.
Jifty->bus->modify(
"$id-render" => sub {
- $_->{$channel} = {
+ $_->{$channel}{$region} = {
map { $_ => $args->{$_} }
qw/render_with region arguments mode/
};
@@ -108,7 +109,7 @@
}
);
- return "$channel!$id";
+ return "$channel!$id!$region";
}
=head2 cancel CHANNEL_ID
@@ -125,28 +126,32 @@
return undef;
}
- my ($channel, $id) = split(/!/, $channel_id, 2);
+ my ($channel, $id, $region) = split(/!/, $channel_id, 3);
my ($event_class) = split(/-/, $channel);
$id ||= Jifty->web->session->id;
- Jifty->bus->modify(
- "$event_class-subscriptions" => sub {
- delete $_->{$channel};
- }
- );
-
+ my $last;
Jifty->bus->modify(
"$id-render" => sub {
- delete $_->{$channel};
+ delete $_->{$channel}{$region};
+ $last = 1 unless %{$_->{$channel}};
}
);
- Jifty->bus->modify(
- "$id-subscriber" => sub {
- if ($_) { $_->unsubscribe($channel) }
- }
- );
+ if ($last) {
+ Jifty->bus->modify(
+ "$event_class-subscriptions" => sub {
+ delete $_->{$channel};
+ }
+ );
+
+ Jifty->bus->modify(
+ "$id-subscriber" => sub {
+ if ($_) { $_->unsubscribe($channel) }
+ }
+ );
+ }
}
=head2 list [window/sessionid]
Modified: jifty/trunk/lib/Jifty/Subs/Render.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Subs/Render.pm (original)
+++ jifty/trunk/lib/Jifty/Subs/Render.pm Tue Jul 29 19:00:01 2008
@@ -46,8 +46,6 @@
# XXX - We don't yet use $timestamp here.
my ( $timestamp, $msg ) = @$rv;
-
-
# Channel name is always App::Event::Class-MD5QUERIES
my $event_class = $channel;
$event_class =~ s/-.*//;
@@ -59,26 +57,27 @@
Jifty->log->debug("Rendering $channel event $msg");
- my $render_info = $render->{$channel};
- my $region = Jifty::Web::PageRegion->new(
- name => $render_info->{region},
- path => $render_info->{render_with},
- );
- delete Jifty->web->{'regions'}{ $region->qualified_name };
-
- # Finally render the region. In addition to the user-supplied arguments
- # in $render_info, we always pass the target $region and the event object
- # into its %ARGS.
- my $region_content = '';
- my $event_object = $event_class->new($msg);
- $region->render_as_subrequest( \$region_content,
- { %{ $render_info->{arguments} || {} },
- event => $event_object,
- $event_object->render_arguments,
- }
- );
- $callback->( $render_info->{mode}, $region->qualified_name, $region_content);
- $sent++;
+ for my $render_info (values %{$render->{$channel}}) {
+ my $region = Jifty::Web::PageRegion->new(
+ name => $render_info->{region},
+ path => $render_info->{render_with},
+ );
+ delete Jifty->web->{'regions'}{ $region->qualified_name };
+
+ # Finally render the region. In addition to the user-supplied arguments
+ # in $render_info, we always pass the target $region and the event object
+ # into its %ARGS.
+ my $region_content = '';
+ my $event_object = $event_class->new($msg);
+ $region->render_as_subrequest( \$region_content,
+ { %{ $render_info->{arguments} || {} },
+ event => $event_object,
+ $event_object->render_arguments,
+ }
+ );
+ $callback->( $render_info->{mode}, $region->qualified_name, $region_content);
+ $sent++;
+ }
}
}
return ($sent);
More information about the Jifty-commit
mailing list