Re: Casting around for ideas...

[prev] [thread] [next] [Date index for 2005/05/23]

From: Matt S Trout
Subject: Re: Casting around for ideas...
Date: 17:04 on 23 May 2005
On Mon, May 23, 2005 at 10:16:41AM +0100, Nic Gibson wrote:
> >>The other part comes down to:
> >>
> >>    Imagine that I have the above working.
> >>    The conventional way to set the DBI connection is via a shared
> >>base.
> >>
> >>    I have the following packages.
> >>
> >>        Foo::Bar
> >>        MyApp::One
> >>        MyApp::Two
> >>
> >>Now, Foo::Bar is derived from Foo. MyApp::One and MyApp::Two are
> >>derived from
> >>MyApp::Base. Foo is a generic package and doesn't have a base class
> >>that defines
> >>a connection in the same way.
> >>
> >
> >Well, my way of doing it would be to get something suitable onto  
> >the head
> >of the packages' @INC somehow - say
> >
> >package Foo::Bar;
> >
> >use base qw/Foo CurrentConnection/;
> >
> >but have CurrentConnection *not* do ->connection. Then in your user  
> >code you
> >can do
> >
> >use CurrentConnection;
> >
> >CurrentConnection->connection(...);
> >
> >use Foo::Bar;
> 
> This has potential although I can see it causing issues in, say  
> mod_perl  environments. Our applications tend to work in both web and  
> cron job environments - the front end in the web and cron jobs doing  
> things that modify the file system/send mail/etc. The approach I've  
> been mulling over  has similarities to this but needs to instantiate  
> something rather than use a class method - otherwise two web  
> applications running in the same apache child will get the same  
> database connection. Must get this worked out :)

Not if you keep each copy of the application in it's own Safe::World
compartment, it won't. I've been meaning to write code for this for *ages*,
but haven't quite got round to it yet.

        -- 
             Matt S Trout           Website: http://www.shadowcatsystems.co.uk
  Technical Director        E-mail:  mst (at) shadowcatsystems.co.uk
Shadowcat Systems Ltd.

(message missing)

Casting around for ideas...
Nic Gibson 00:08 on 22 May 2005

Re: Casting around for ideas...
Jay Strauss 14:30 on 22 May 2005

Re: Casting around for ideas...
Nic Gibson 18:40 on 22 May 2005

Re: Casting around for ideas...
Matt S Trout 19:02 on 22 May 2005

Re: Casting around for ideas...
Nic Gibson 09:16 on 23 May 2005

Re: Casting around for ideas...
Tony Bowden 09:24 on 23 May 2005

Re: Casting around for ideas...
Matt S Trout 17:04 on 23 May 2005

Re: Casting around for ideas...
Nic Gibson 09:29 on 23 May 2005

Generated at 15:51 on 25 May 2005 by mariachi v0.52