Re: Casting around for ideas...

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

From: Matt S Trout
Subject: Re: Casting around for ideas...
Date: 19:02 on 22 May 2005
On Sun, May 22, 2005 at 07:40:45PM +0100, Nic Gibson wrote:
> OK. I read my own email again this morning (don't write email at 1am)  
> and it really
> doesn't make a lot of sense.
> 
> An example, I have a package Foo. I need to use this in several  
> places, all slightly
> modified. Therefore, I create Foo::Bar. This will maybe have a new  
> column.
> 
> However, I seem to be having a problem using Foo::Bar - I get errors  
> that appear
> to show that the __grouper attribute of Foo::Bar is empty - not  
> getting the columns.
> from Foo. That may be caused by something else I do, not sure what.

I think it's down to the way Class::Data::Inheritable works. Maybe try

__PACKAGE__->__grouper(__PACKAGE__->__grouper)

first or something.
 
> 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;

<continue as normal>

Other similar tricks will work - you could even find all your table packages
and do an unshift('Connection::Class', @{"${package}::INC"});

        -- 
             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