Re: Casting around for ideas...

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

From: Nic Gibson
Subject: Re: Casting around for ideas...
Date: 18:40 on 22 May 2005
On May 22, 2005, at 15:30, Jay Strauss wrote:

> Nic Gibson wrote:
>
>> We've put together a fair amount of code using Class::DBI that
>> represent fairly generic activities that we use in multiple
>> applications/databases (things like an AuditTrail package for
>> example).
>> In 90% of the cases, this simply means the same class with a  
>> different
>> database connection. Sometimes, we add a column or two. I'd really  
>> like
>> to be able to do some reuse here.
>> If I create package Foo and inherit Bar from it, I get errors that
>> look like they are caused by the __grouper class method
>> (Class::DBI::ColumnGrouper) not inheriting from my base
>> ("'xxxx' is not  column of Blah at test.pl line 3" or similar).
>> If I reuse the same package in different locations, I still have a
>> problem of how to associate the package with a particular database  
>> since
>> I would 'normally' use a base package to define the data source.
>> Has anyone tried to do what I'm describing and how did you go about
>> it if you did? I'm hoping that I've missed something obvious here.
>> TIA
>>
>
> Nic,
>
> Are you asking "How do I use the same class with different database  
> connections"?
>
> If so there have been many discussions on this list (and now in the  
> archives), that you could gain some insight from.
>
> If you are asking a different question, I think you may need to  
> restate what you want to do, more clearly with examples
>
> Thanks
> Jay
>
>
>

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 guess part of my question really comes down to -

     does inheritence work properly with CDBI classes?


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.

So... there is no shared base from which I can set a connection. I  
don't really want to
have to have multiple connections although it's not a real crisis. I  
was just wondering
whether anyone else is doing this, whether I'm going down a stupid  
path or whether
I've totally failed to grasp something obvious. I've been reading the  
list for some time
now and none of the 'how do I reuse this package across applications'  
questions
really seems to ask the above. Given chronic lack of sleep (9 month  
old), I may be
missing something obvious or doing something stupid with the above  
scenario.

Does that state the problem better?

cheers

nic



(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