Re: [RDBO] Sharing a DBI connection with Class::DBI
On Jan 29, 2008 10:32 PM, John Siracusa <[EMAIL PROTECTED]> wrote: > On 1/29/08, Sam Tregar <[EMAIL PROTECTED]> wrote: > > Do you happen to know if RDBO will tolerate a > > DBIx::ContextualFetch based DBI handle? > It should, and if it doesn't, I can probably make it do so with some > minor edits. Give of a try and let me know. > Looks pretty good. I setup a hacked Rose::DB with RootClass set to DBIx::ContextualFetch by default and ran the Rose::DB::Object test suite against it with MySQL. Everything passed. I'll let you know if I see anything odd when I try to actually use it myself. -sam - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
Re: [RDBO] Sharing a DBI connection with Class::DBI
On 1/29/08, Sam Tregar <[EMAIL PROTECTED]> wrote: > Do you happen to know if RDBO will tolerate a > DBIx::ContextualFetch based DBI handle? It should, and if it doesn't, I can probably make it do so with some minor edits. Give of a try and let me know. -John - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
Re: [RDBO] Sharing a DBI connection with Class::DBI
On Jan 29, 2008 10:06 PM, John Siracusa <[EMAIL PROTECTED]> wrote: > > The "db" atribute of an RDBO-derived object "isa" Rose::DB, but each > Rose::DB-derived object "has a" DBI $dbh. IOW, plain old DBI database > handles are used via delegation in RDBO. There's no subclassing of > DBI classes at all. > Good to hear. Do you happen to know if RDBO will tolerate a DBIx::ContextualFetch based DBI handle? but keep in mind the new new_or_cached() Rose::DB method that makes a > lot of the caching discussion in some older threads less relevant > these days. > > http://search.cpan.org/dist/Rose-DB/lib/Rose/DB.pm#new_or_cached > Yes, I found that one - seems very useful. Maybe something to add to the tutorial? Thanks for the help! -sam - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
Re: [RDBO] Sharing a DBI connection with Class::DBI
On Jan 29, 2008 9:57 PM, Sam Tregar <[EMAIL PROTECTED]> wrote: > On Jan 29, 2008 9:55 PM, Peter Karman <[EMAIL PROTECTED]> wrote: > > just a naive guess here, but if you were using DBI->connect_cached as the > > underlying connect method, wouldn't DBI handle the sharing for you? > > > > No, I'm pretty sure DBI uses the class as part of the connect_cached key. And as for DBI's, connect_cached(), you can use that (instead of the default connect()) in Rose::DB by overriding dbi_connect() in your Rose::DB subclass: http://search.cpan.org/dist/Rose-DB/lib/Rose/DB.pm#dbi_connect -John - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
Re: [RDBO] Sharing a DBI connection with Class::DBI
On Jan 29, 2008 9:52 PM, Sam Tregar <[EMAIL PROTECTED]> wrote: > Hey all. I'm getting started with Rose::DB::Object. My problem is I need > to inter-operate with a large pre-existing Class::DBI code-base. I'd like > to setup Rose to be able to share the same DBI connection that Class::DBI > uses - otherwise I'll instantly double the number of connections from our > web cluster when I roll out Rose::DB::Object. > > I know of one problem - Class::DBI requires its DBI handles to inherit from > DBIx::ContextualFetch while Rose wants its handle to inherit from > Rose::DB::MySQL. Anybody know how to solve this? Alternately, do you know > of other reasons why it won't work? The "db" atribute of an RDBO-derived object "isa" Rose::DB, but each Rose::DB-derived object "has a" DBI $dbh. IOW, plain old DBI database handles are used via delegation in RDBO. There's no subclassing of DBI classes at all. As for sharing, if you already have a DBI $dbh from elsewhere, you can simply stuff it into an appropriate Rose::DB object and use that as the "db" value in RDBO objects and calls. Just make sure that the Rose::DB object has the same driver as the DBI $dbh. Example: $dbh = ...; # get from elsewhere $db = Rose::DB->new(driver => 'mysql', dbh => $dbh); Overriding init_db() in a common base class is the usual way to do this "everywhere." There are many possible policies for init_db(). You can find a few old threads on the topic in the list archives: http://www.mail-archive.com/rose-db-object@lists.sourceforge.net/maillist.html but keep in mind the new new_or_cached() Rose::DB method that makes a lot of the caching discussion in some older threads less relevant these days. http://search.cpan.org/dist/Rose-DB/lib/Rose/DB.pm#new_or_cached Also keep in mind the funky (but useful! :) mod_perl-aware default behavior of new_or_cached()'s default cache backend: http://search.cpan.org/dist/Rose-DB/lib/Rose/DB/Cache.pm#prepare_db -John - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
Re: [RDBO] Sharing a DBI connection with Class::DBI
On Jan 29, 2008 9:55 PM, Peter Karman <[EMAIL PROTECTED]> wrote: > just a naive guess here, but if you were using DBI->connect_cached as the > underlying connect method, wouldn't DBI handle the sharing for you? > No, I'm pretty sure DBI uses the class as part of the connect_cached key. -sam - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object
Re: [RDBO] Sharing a DBI connection with Class::DBI
Sam Tregar wrote on 1/29/08 8:52 PM: > Hey all. I'm getting started with Rose::DB::Object. My problem is I need > to inter-operate with a large pre-existing Class::DBI code-base. I'd like > to setup Rose to be able to share the same DBI connection that Class::DBI > uses - otherwise I'll instantly double the number of connections from our > web cluster when I roll out Rose::DB::Object. > > I know of one problem - Class::DBI requires its DBI handles to inherit from > DBIx::ContextualFetch while Rose wants its handle to inherit from > Rose::DB::MySQL. Anybody know how to solve this? Alternately, do you know > of other reasons why it won't work? > just a naive guess here, but if you were using DBI->connect_cached as the underlying connect method, wouldn't DBI handle the sharing for you? -- Peter Karman . http://peknet.com/ . [EMAIL PROTECTED] - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object