Hi Derek

Michale has answered your question, so I just say the same thing
differently.

(After all, remeber that joke: We're all going down the same road in
different directions...)

On Thu, 2009-03-19 at 08:35 -0700, Derek Walker wrote:
> I'm writing a very basic app under apache + mod_perl.
> 
> I've made the super vanilla instance script and application module.
> 
> =====
> #!/usr/bin/perl
> use lib '/var/www/html/infra';
> use Physical;
> 
> my $app = Physical->new();
> $app->run();

Or, even better:

Physical -> new() -> run()

since $app is never used in any meaningful way.

Years ago I proposed a doc patch on this very issue...

> I'm running into the old chestnut of a problem of how to properly
> 'wrap' a perl application under mod_perl to avoid the shared global
> variable issue (that I only partially understand at this point)

To me this is a design problem, not a coding problem.

Of course it matters what you mean by 'wrap', but I'd suggest stop
thinking in terms of wrapping and start thinking in terms of re-design.

> Reading from a couple of books and web sites I can see the basics of
> how to wrap things to avoid this collision, but I can't quite make it
> work for my basic test app.

Vague guideline:

o Create Physical object.

o In its constructor, create db handle etc which are local to the
Physical object.

o Hence, let the lifetime of the Physical object control the lifetime of
that object's attributes.


-- 
Ron Savage
[email protected]
http://savage.net.au/index.html



#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################

Reply via email to