[Catalyst-commits] r9309 - in Catalyst-Runtime/5.80/trunk: . lib/Catalyst/Engine/HTTP t

t0m at dev.catalyst.perl.org t0m at dev.catalyst.perl.org
Sun Feb 15 05:17:19 GMT 2009


Author: t0m
Date: 2009-02-15 05:17:19 +0000 (Sun, 15 Feb 2009)
New Revision: 9309

Modified:
   Catalyst-Runtime/5.80/trunk/Changes
   Catalyst-Runtime/5.80/trunk/lib/Catalyst/Engine/HTTP/Restarter.pm
   Catalyst-Runtime/5.80/trunk/t/optional_http-server-restart.t
Log:
Immutable components no longer break the restarter for the simple case

Modified: Catalyst-Runtime/5.80/trunk/Changes
===================================================================
--- Catalyst-Runtime/5.80/trunk/Changes	2009-02-15 01:59:44 UTC (rev 9308)
+++ Catalyst-Runtime/5.80/trunk/Changes	2009-02-15 05:17:19 UTC (rev 9309)
@@ -1,5 +1,8 @@
 # This file documents the revision history for Perl extension Catalyst.
 
+        - Naive implementation of making packages mutable before restarting so
+          that restarter works with native Moose apps using immutable (t0m)
+          - Tests for this (t0m)
         - Bump Moose dependency to 0.70 so that we avoid nasty surprises
           with is_class_loaded and perl 5.80 when you Moosify MyApp.pm (t0m)
         - Clarify that request arguments aren't unescaped automatically

Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst/Engine/HTTP/Restarter.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/Engine/HTTP/Restarter.pm	2009-02-15 01:59:44 UTC (rev 9308)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/Engine/HTTP/Restarter.pm	2009-02-15 05:17:19 UTC (rev 9309)
@@ -1,6 +1,8 @@
 package Catalyst::Engine::HTTP::Restarter;
+use Moose;
+use Moose::Util qw/find_meta/;
+use namespace::clean -except => 'meta';
 
-use Moose;
 extends 'Catalyst::Engine::HTTP';
 
 use Catalyst::Engine::HTTP::Restarter::Watcher;
@@ -18,6 +20,8 @@
         close STDIN;
         close STDOUT;
 
+        $self->_make_components_mutable($class);
+
         my $watcher = Catalyst::Engine::HTTP::Restarter::Watcher->new(
             directory => ( 
                 $options->{restart_directory} || 
@@ -70,8 +74,18 @@
     return $self->$orig( $class, $port, $host, $options );
 };
 
-no Moose;
+# Naive way of trying to avoid Moose blowing up when you re-require components
+# which have been made immutable.
+sub _make_components_mutable {
+    my ($self, $class) = @_;
 
+    my @metas = map { find_meta(@_) } ($class, map { blessed($_) } values %{ $class->components });
+
+    foreach my $meta (@metas) {
+        $meta->make_mutable if $meta->is_immutable;
+    }
+}
+
 1;
 __END__
 

Modified: Catalyst-Runtime/5.80/trunk/t/optional_http-server-restart.t
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/optional_http-server-restart.t	2009-02-15 01:59:44 UTC (rev 9308)
+++ Catalyst-Runtime/5.80/trunk/t/optional_http-server-restart.t	2009-02-15 05:17:19 UTC (rev 9309)
@@ -65,7 +65,7 @@
 my @files = (
     "$FindBin::Bin/../t/tmp/TestApp/lib/TestApp.pm",
     "$FindBin::Bin/../t/tmp/TestApp/lib/TestApp/Controller/Action/Begin.pm",
-"$FindBin::Bin/../t/tmp/TestApp/lib/TestApp/Controller/Engine/Request/URI.pm",
+    "$FindBin::Bin/../t/tmp/TestApp/lib/TestApp/Controller/Immutable.pm",
 );
 
 # change some files and make sure the server restarts itself




More information about the Catalyst-commits mailing list