Re: Casting around for ideas...
[prev]
[thread]
[next]
[Date index for 2005/05/22]
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)
|