Hi all,

Thank you Alan, Hans, and Ben for your replies!  The good news is that 
Hans' suggestion worked; the "bad" news is that I don't understand one 
point still and am wondering if someone could explain it to me even 
though it seems like "basic Perl"...

What I have now is:

{
  package HTML::Mason::Commands;
  use MyUtils;
}

May I ask what is the purpose of these parentheses?  I know they limit 
scope, so its purpose is to incorporate "MyUtils" into the package 
HTML::Mason::Commands only and not affect anything else in my handler 
file (i.e., the file that my handler is in)?  I also have other "use" 
statements in the file:

use Apache2::Status ( );
use HTML::Mason::ApacheHandler;
use Apache2::Const -compile => ':common';
use Apache2::Upload;
use Benchmark;

how do I decide whether they should also be included in or does it not 
matter?  The site seems to work whether I put them in or leave them at 
the current location [top of the file].  How do I decide?  My guess is 
that they should be left out because they are not used *by* 
HTML::Mason::Commands...but with it.


BenRifkah Bergsten-Buret wrote:
> I second this method recommended by Hans.  I strongly recommend staying away
> from putting use statements in all of your components if you run Mason under
> mod_perl.  This can lead to intermittent bugs due to race conditions if you
> forget to put a use statement in a component where the code uses a module.
>
> For example you write component a including a "use CGI" statement and
> instanciates a CGI object.  Later you work on component b and instanciate a
> CGI object.  When you test component B it works fine in development because
> you've already tested component A which loaded CGI into the embedded perl
> runtime.  However, when you push code to production or restart the server
> you may find that sometimes component B doesn't work.  This happens because
> you forgot to include a use CGI statement in component B.
>   


Argh...yes, you actually described a problem that I *was* encountering 
during development and rather than thinking of a better way to do it, I 
was blaming myself for forgetting the "use" statement.  I finally 
guessed that maybe rather than blaming myself, I should find a better 
way to do it.


> Using all of your modules in your mason handler will ensure that you never
> have to deal with such a race condition.
>
> I've never used the PerlModule directive before but the mod_perl 2.0
> documentation says that it's the equivalent of doing a "require MyModule"
> which isn't exactly the same as a use statement.  perldoc -f use for
> details.
>   


This was another one of my problems...I was doing "PerlModule" and 
didn't realize it doesn't do an "import" so I thought something else was 
going wrong.  I was having many inconsistencies during 
development...Mason compilation problems that were not repeatably 
easily.  I see why now...

Thank you for the help!

Ray



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to