[Catalyst-commits] r6465 - in trunk: .
Catalyst-Component-ACCEPT_CONTEXT
Catalyst-Component-ACCEPT_CONTEXT/lib/Catalyst/Component
Catalyst-Component-ACCEPT_CONTEXT/t
Catalyst-Component-ACCEPT_CONTEXT/t/lib
Catalyst-Component-ACCEPT_CONTEXT/t/lib/TestApp/Controller
Catalyst-Component-ACCEPT_CONTEXT/t/lib/TestApp/Model
jrockway at dev.catalyst.perl.org
jrockway at dev.catalyst.perl.org
Wed Jun 13 14:58:49 GMT 2007
Author: jrockway
Date: 2007-06-13 14:58:39 +0100 (Wed, 13 Jun 2007)
New Revision: 6465
Added:
trunk/Catalyst-Component-ACCEPT_CONTEXT/t/02-live-stash.t
trunk/Catalyst-Component-ACCEPT_CONTEXT/t/lib/TestApp/Model/StashMe.pm
Modified:
trunk/
trunk/Catalyst-Component-ACCEPT_CONTEXT/Changes
trunk/Catalyst-Component-ACCEPT_CONTEXT/MANIFEST
trunk/Catalyst-Component-ACCEPT_CONTEXT/Makefile.PL
trunk/Catalyst-Component-ACCEPT_CONTEXT/lib/Catalyst/Component/ACCEPT_CONTEXT.pm
trunk/Catalyst-Component-ACCEPT_CONTEXT/t/lib/TestApp.pm
trunk/Catalyst-Component-ACCEPT_CONTEXT/t/lib/TestApp/Controller/Root.pm
Log:
r26670 at foo: jon | 2007-06-13 08:21:44 -0500
fix a bug where $c is not passed to NEXT classes; fix memory bug; add tests; release 0.03
Property changes on: trunk
___________________________________________________________________
Name: svk:merge
- 6d2a1d83-d666-409f-9dbf-d3bfcf4e9009:/local_branches/Catalyst-bad-mst/trunk:40156
6d2a1d83-d666-409f-9dbf-d3bfcf4e9009:/local_branches/Catalyst-broken-net/trunk:19004
6d2a1d83-d666-409f-9dbf-d3bfcf4e9009:/local_branches/Catalyst_acl_in_conf/trunk:3134
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst-trunk:26646
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/trunk:7830
dd8ad9ea-0304-0410-a433-df5f223e7bc0:/local/Catalyst/trunk:7023
+ 6d2a1d83-d666-409f-9dbf-d3bfcf4e9009:/local_branches/Catalyst-bad-mst/trunk:40156
6d2a1d83-d666-409f-9dbf-d3bfcf4e9009:/local_branches/Catalyst-broken-net/trunk:19004
6d2a1d83-d666-409f-9dbf-d3bfcf4e9009:/local_branches/Catalyst_acl_in_conf/trunk:3134
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst-trunk:26670
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/trunk:7830
dd8ad9ea-0304-0410-a433-df5f223e7bc0:/local/Catalyst/trunk:7023
Modified: trunk/Catalyst-Component-ACCEPT_CONTEXT/Changes
===================================================================
--- trunk/Catalyst-Component-ACCEPT_CONTEXT/Changes 2007-06-13 03:21:46 UTC (rev 6464)
+++ trunk/Catalyst-Component-ACCEPT_CONTEXT/Changes 2007-06-13 13:58:39 UTC (rev 6465)
@@ -1,4 +1,7 @@
Revision history for Catalyst-Component-ACCEPT_CONTEXT
+0.03 13 Jul 2007
+ Weaken context.
+
0.01 18 Feb 2007
First version, released on an unsuspecting world.
Modified: trunk/Catalyst-Component-ACCEPT_CONTEXT/MANIFEST
===================================================================
--- trunk/Catalyst-Component-ACCEPT_CONTEXT/MANIFEST 2007-06-13 03:21:46 UTC (rev 6464)
+++ trunk/Catalyst-Component-ACCEPT_CONTEXT/MANIFEST 2007-06-13 13:58:39 UTC (rev 6465)
@@ -17,9 +17,11 @@
README
t/00-load.t
t/01-live.t
+t/02-live-stash.t
t/boilerplate.t
t/lib/TestApp.pm
t/lib/TestApp/Controller/Root.pm
+t/lib/TestApp/Model/StashMe.pm
t/lib/TestApp/Model/Test.pm
t/lib/TestApp/View/Test.pm
t/pod-coverage.t
Modified: trunk/Catalyst-Component-ACCEPT_CONTEXT/Makefile.PL
===================================================================
--- trunk/Catalyst-Component-ACCEPT_CONTEXT/Makefile.PL 2007-06-13 03:21:46 UTC (rev 6464)
+++ trunk/Catalyst-Component-ACCEPT_CONTEXT/Makefile.PL 2007-06-13 13:58:39 UTC (rev 6465)
@@ -5,7 +5,8 @@
name 'Catalyst-Component-ACCEPT_CONTEXT';
all_from 'lib/Catalyst/Component/ACCEPT_CONTEXT.pm';
requires 'Catalyst';
-build_requires 'Test::More';
+requires 'Scalar::Util';
+build_requires 'Devel::Cycle';
auto_install;
WriteAll;
Modified: trunk/Catalyst-Component-ACCEPT_CONTEXT/lib/Catalyst/Component/ACCEPT_CONTEXT.pm
===================================================================
--- trunk/Catalyst-Component-ACCEPT_CONTEXT/lib/Catalyst/Component/ACCEPT_CONTEXT.pm 2007-06-13 03:21:46 UTC (rev 6464)
+++ trunk/Catalyst-Component-ACCEPT_CONTEXT/lib/Catalyst/Component/ACCEPT_CONTEXT.pm 2007-06-13 13:58:39 UTC (rev 6465)
@@ -4,6 +4,7 @@
use strict;
use NEXT;
use base 'Catalyst::Component';
+use Scalar::Util qw(weaken);
__PACKAGE__->mk_ro_accessors('context'); # TODO: app instead of context initially?
@@ -14,11 +15,11 @@
=head1 VERSION
-Version 0.02
+Version 0.03
=cut
-our $VERSION = '0.02';
+our $VERSION = '0.03';
=head1 SYNOPSIS
@@ -57,8 +58,11 @@
sub ACCEPT_CONTEXT {
my $self = shift;
my $context = shift;
- $self->{context} = $context;
- return $self->NEXT::ACCEPT_CONTEXT(@_) || $self;
+
+ my $new = bless({ %$self, context => $context }, ref($self));
+ weaken($new->{context});
+
+ return $new->NEXT::ACCEPT_CONTEXT($context, @_) || $new;
}
=head2 COMPONENT
@@ -72,6 +76,7 @@
my $app = shift;
my $args = shift;
$args->{context} = $app;
+ weaken($args->{context}) if ref $args->{context};
return $class->NEXT::COMPONENT($app, $args, @_);
}
Added: trunk/Catalyst-Component-ACCEPT_CONTEXT/t/02-live-stash.t
===================================================================
--- trunk/Catalyst-Component-ACCEPT_CONTEXT/t/02-live-stash.t (rev 0)
+++ trunk/Catalyst-Component-ACCEPT_CONTEXT/t/02-live-stash.t 2007-06-13 13:58:39 UTC (rev 6465)
@@ -0,0 +1,15 @@
+#!/usr/bin/perl
+# 02-live-stash.t
+# Copyright (c) 2007 Jonathan Rockway <jrockway at cpan.org>
+
+use strict;
+use warnings;
+use Test::More tests => 2;
+
+use FindBin qw($Bin);
+use lib "$Bin/lib";
+use Catalyst::Test qw(TestApp);
+
+is( get('/stash'), 'it worked', q{stashing doesn't leak} );
+ok( get('/cycle'), 'no cycles');
+
Modified: trunk/Catalyst-Component-ACCEPT_CONTEXT/t/lib/TestApp/Controller/Root.pm
===================================================================
--- trunk/Catalyst-Component-ACCEPT_CONTEXT/t/lib/TestApp/Controller/Root.pm 2007-06-13 03:21:46 UTC (rev 6464)
+++ trunk/Catalyst-Component-ACCEPT_CONTEXT/t/lib/TestApp/Controller/Root.pm 2007-06-13 13:58:39 UTC (rev 6465)
@@ -4,6 +4,7 @@
use strict;
use warnings;
use base 'Catalyst::Controller';
+use Devel::Cycle;
__PACKAGE__->config(namespace => '');
@@ -29,5 +30,21 @@
$c->res->body($c->model('Test')->foo);
}
+sub stash : Global {
+ my ($self, $c) = @_;
+ $c->model('StashMe')->test;
+ $c->res->body($c->stash->{stashme}->foo);
+}
+
+sub cycle : Global {
+ my ($self, $c) = @_;
+ $c->model('StashMe')->test;
+ my $cycle_ok = 1;
+ use Data::Dumper;
+ my $got_cycle = sub { $cycle_ok = 0 };
+ $c->res->body($cycle_ok);
+}
+
+
1;
Added: trunk/Catalyst-Component-ACCEPT_CONTEXT/t/lib/TestApp/Model/StashMe.pm
===================================================================
--- trunk/Catalyst-Component-ACCEPT_CONTEXT/t/lib/TestApp/Model/StashMe.pm (rev 0)
+++ trunk/Catalyst-Component-ACCEPT_CONTEXT/t/lib/TestApp/Model/StashMe.pm 2007-06-13 13:58:39 UTC (rev 6465)
@@ -0,0 +1,19 @@
+#!/usr/bin/perl
+# StashMe.pm
+# Copyright (c) 2007 Jonathan Rockway <jrockway at cpan.org>
+
+package TestApp::Model::StashMe;
+use strict;
+use warnings;
+use base qw(Catalyst::Component::ACCEPT_CONTEXT Catalyst::Model);
+
+sub test {
+ my $self = shift;
+ $self->context->stash(stashme => $self);
+}
+
+sub foo {
+ return "it worked";
+}
+
+1;
Modified: trunk/Catalyst-Component-ACCEPT_CONTEXT/t/lib/TestApp.pm
===================================================================
--- trunk/Catalyst-Component-ACCEPT_CONTEXT/t/lib/TestApp.pm 2007-06-13 03:21:46 UTC (rev 6464)
+++ trunk/Catalyst-Component-ACCEPT_CONTEXT/t/lib/TestApp.pm 2007-06-13 13:58:39 UTC (rev 6465)
@@ -8,3 +8,4 @@
TestApp->config(foo => 'baz');
TestApp->setup;
1;
+
More information about the Catalyst-commits
mailing list