Loading ...
Sorry, an error occurred while loading the content.

Apache::Reload: explicitly registering required library files [p atch included]

Expand Messages
  • Bevelock, Mike
    A nice enhancement to Apache::Reload would be the ability to explicitly register and reload required library files. For example, if a sub in
    Message 1 of 2 , Jul 2, 2004
    • 0 Attachment
      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
    • Perrin Harkins
      ... It won t with this patch, unless common_subs.pl declares a package. If common_subs.pl is just a bunch of subs that get pulled into the current script s
      Message 2 of 2 , Jul 2, 2004
      • 0 Attachment
        Bevelock, Mike wrote:
        > 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.

        It won't with this patch, unless common_subs.pl declares a package. If
        common_subs.pl is just a bunch of subs that get pulled into the current
        script's namespace, Apache::Reload can't change them.

        - Perrin

        --
        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
      Your message has been successfully submitted and would be delivered to recipients shortly.