[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-modperl
Subject:    Re: [mp2] Apache2::Reload doesn't reload
From:       "Perrin Harkins" <perrin () elem ! com>
Date:       2007-07-11 3:28:07
Message-ID: 66887a3d0707102028i36f19494xcdd596882468c903 () mail ! gmail ! com
[Download RAW message or body]

On 6/27/07, Colin Wetherbee <cww@denterprises.org> wrote:
> I have a handler in a module called JetSet::Handler.  That module
> depends on a number of other modules, which I've tried to include with
> 'use', with limited success.  It seems, sometimes, symbols act just fine
> and reload when they should, but other times, I have to restart Apache
> in order to get the symbols to reload.

You have to understand, Perl has no support for reloading modules.
What Reload and similar modules do (clearing the symbol table and %INC
and loading the module again) usually works, but it's never going to
be work for 100% of all perl code because it's not an actual language
feature.

> # In Handler.pm:
> require JetSet::Debug; JetSet::Debug->import();
> # ...
>    JetSet::Debug::DebugLevel(JetSet::Debug::DEBUG_WARN);
> # End

Why import it at all if you're going to fully qualify it like that?
Is this your actual code?

> # From error_log:
> failed to resolve handler `JetSet::Handler': Bareword
> "JetSet::Debug::DEBUG_WARN" not allowed while "strict subs" in use at
> /home/cww/sites/rain/htdocs/jet-set/JetSet/Handler.pm line 19.

You can declare the sub names with the "use subs" pragma.  Adding
parentheses on the end of DEBUG_WARN might help too.

> I'm not opposed to doing that, but in that case, how does one deal with
> things like constants?

I think what you're really asking here is how do you handle
configuring your application.  There are many ways to do it.  I
usually end up having a configuration object of some kind, usually
implemented as a singleton.  And yes, I restart when I want to change
them.  It's fairly easy to implement a periodic check for changes in
your config file though, if you want to.  Things like Log4Perl have
this built in.

Or, if you really did mean constants, I put them in the files where
they are used, and never touch them, since they are... constants.

- Perrin
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic