On 8/7/06 4:04 PM, "John Siracusa" <[EMAIL PROTECTED]> wrote:

> On 8/7/06 3:40 PM, Sean Davis wrote:
>> On 8/7/06 1:31 PM, "Sean Davis" <[EMAIL PROTECTED]> wrote:
>>> I am trying to write some code to access a publicly available data source.
>>> It consists of a few dozen different databases (mysql), all with the same
>>> table structure, pretty much.  I would also like to allow users to query a
>>> local mirror of the data source, as well.  Therefore, I would like to make a
>>> set of classes that can be "used" to do so, supplying the connection
>>> parameters on-the-fly.  I don't see an easy way to supply the variable
>>> database connection information to a "default" Rose::DB class.  Is this
>>> possible?  If so, can someone give me a little hint?
>> 
>> I can use ->modify_db, it looks like.  Sorry for the chatter.
> 
> Also consider making multiple sets of data sources, either using the
> "domain" Rose::DB data source attribute ("local", "mirror", "main") or
> perhaps prefixing the "type" attribute  with "local:", "mirror:", or "main:"
> 
> Then all you have to do in the classes to get the right db is pick the right
> arguments in the init_db method.  Here's an example using just the "type":
> 
>     package My::DB::Whatever;
>     ...
>     sub init_db
>     {
>       my $type = <figure out correct db type for this class>
>       return My::DB->new($type);
>     }
> 
> The "figure out correct db type for this class" can perhaps look at the
> class name and see if it has "::Mirror::" in it or whatever.

Thanks again, John, for the reply.

This is what I thought of first, but the user of a "mirror" or "local"
database will want to set up his/her username/password, hostname, etc.  So,
I probably need finer, more flexible control than this; the level of the
Rose::DB subclass seems the right level, with users just calling class
methods before doing any object instantiation.  Is there a big downside to
doing things this way?

The ideological constraint (based on history, not anything else) that I am
trying to satisfy is basically that these modules will be used from a
script, with no subclassing or access to the modules necessary other than
class or object method calls.

Sean

Sean


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to