You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl-cvs@perl.apache.org by ph...@apache.org on 2010/02/09 22:37:21 UTC

svn commit: r908240 - in /perl/Apache-Reload/trunk: Changes lib/Apache/Reload.pm

Author: phred
Date: Tue Feb  9 21:37:20 2010
New Revision: 908240

URL: http://svn.apache.org/viewvc?rev=908240&view=rev
Log:
'no Apache::Reload' option to ignore reloading modules with that directive.

When Moose is being used, reloading a class will probably result in it being unusable.

Especially if the class uses roles or any of the method wrapping calls.

This adds "no Apache::Reload" to make sure that such modules are not attempted to be reloaded.

Submitted by:  Graham Barr <gb...@pobox.com>
Signed off by:  Fred Moyer <ph...@apache.org>g

Modified:
    perl/Apache-Reload/trunk/Changes
    perl/Apache-Reload/trunk/lib/Apache/Reload.pm

Modified: perl/Apache-Reload/trunk/Changes
URL: http://svn.apache.org/viewvc/perl/Apache-Reload/trunk/Changes?rev=908240&r1=908239&r2=908240&view=diff
==============================================================================
--- perl/Apache-Reload/trunk/Changes (original)
+++ perl/Apache-Reload/trunk/Changes Tue Feb  9 21:37:20 2010
@@ -8,6 +8,10 @@
 
 =item 0.11-dev
 
+Add a no Apache::Reload directive which skips reloading for modules
+that have it included (useful for Moose compatibility).
+[Graham Barr, <gb...@pobox.com>]
+
 Add Empty NOTICE file
 http://rt.cpan.org/Ticket/Display.html?id=34786
 [Niko Tyni (Debian Perl Group) <nt...@debian.org>]

Modified: perl/Apache-Reload/trunk/lib/Apache/Reload.pm
URL: http://svn.apache.org/viewvc/perl/Apache-Reload/trunk/lib/Apache/Reload.pm?rev=908240&r1=908239&r2=908240&view=diff
==============================================================================
--- perl/Apache-Reload/trunk/lib/Apache/Reload.pm (original)
+++ perl/Apache-Reload/trunk/lib/Apache/Reload.pm Tue Feb  9 21:37:20 2010
@@ -32,6 +32,13 @@
     $class->register_module($package, $file);
 }
 
+sub unimport {
+    my $class = shift;
+    my ($package,$file) = (caller)[0,1];
+
+    $class->unregister_module($package, $file);
+}
+
 sub package_to_module {
     my $package = shift;
     $package =~ s/::/\//g;
@@ -58,6 +65,13 @@
     }
 }
 
+sub unregister_module {
+    my ($class, $package, $file) = @_;
+    my $module = package_to_module($package);
+
+    $Ignore{$module} = 1;
+}
+
 sub handler {
     my $r = shift;
     
@@ -135,9 +149,14 @@
         }
 		# remove the modules
         if ($mtime > $Stat{$file}) {
-            delete $INC{$key};
-            push @changed, $key;
-	 	}
+            if ($Ignore{$key}) {
+                warn "Apache::Reload: Not reloading $key\n";
+            }
+            else {
+                delete $INC{$key};
+                push @changed, $key;
+            }
+        }
         $Stat{$file} = $mtime;
     }
 
@@ -230,6 +249,15 @@
 Note that these are split on whitespace, but the module list B<must>
 be in quotes, otherwise Apache tries to parse the parameter list.
 
+=head2 Un-Register Modules Explicitly
+
+If ReloadAll is set to On, then you can explicity force a module not to be reloaded with
+
+  no Apache::Reload;
+
+A warning will appear in the error log that the file has changed, but will
+not be reloaded
+
 =head2 Special "Touch" File
 
 You can also set a file that you can touch() that causes the reloads to be