perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bevelock, Mike" <bevel...@buffalo.edu>
Subject Apache::Reload: explicitly registering required library files [p atch included]
Date Fri, 02 Jul 2004 15:52:28 GMT
A nice enhancement to Apache::Reload would be the ability to explicitly
"register" and reload required library files.

For example, if a sub in 'lib/common_subs.pl' changed, it would be nice if
all code
that did this:

require 'lib/common_subs.pl';

got the fresh code in lib/common_subs.pl.

The Apache::Reload->register_module method expects the "thing" your
registering
to be in a "package" format (eg Foo::Bar).  It therefore calls
package_to_module, which converts
:: to /, and appends a .pm to the "thing", before adding it to
%Apache::Reload::INCS.

Therefore, this
Apache::Reload->register_module('lib/common_subs.pl');
doesn't work as one might expect.

I added this functionality to my local copy of Apache::Reload ver 0.07.

Appended to this mail is a diff of the change.

note: if ReloadAll is on, I believe that required libs do indeed get
refreshed.
I'm not setting ReloadAll and am explicidly registering modules (and libs).

Any comments to this change?
Should/could this be incorporated into Apache::Reload?


Thank you,
Mike
University at Buffalo

http://search.cpan.org/src/MSERGEANT/Apache-Reload-0.07/Reload.pm


>diff -c Reload.pm Reload.pm.new
*** Reload.pm   Thu Jul  1 16:07:15 2004
--- Reload.pm.new       Thu Jul  1 16:07:45 2004
***************
*** 28,33 ****
--- 28,40 ----
  
  sub register_module {
      my ($class, $package, $file) = @_;
+ 
+     if ($INC{$package}) { 
+       # if it's in %INC, it's already in "module" format,
+       # just add it to %Apache::Reload::INCS and return
+       $INCS{$package} = $INC{$package};
+       return;
+     }
      my $module = package_to_module($package);
      
      if ($file) {

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Mime
View raw message