Re: [RDBO] overloading Rose::DB->dbh

2007-02-08 Thread Michael Reece
thanks, jonathan.

that is (roughly) the approach i tried after sending my last mail,

   package Vinq::RDBO::_mysql;
   use base 'Rose::DB::Object';

   use strict;
   use warnings;

   use Vinq::Globals qw($dbh);
   use Vinq::RDB::MySQL;

   our $MAKING_CLASSES = 0;

   sub init_db {
 my $_dbh = $dbh;# Global
 if ($MAKING_CLASSES) {
 ## RDBO has trouble auto_initializing from Vinq::DB, so get  
'pure' dbh
 $dbh->_connect if $dbh->{connectionNeeded};
 $_dbh = $dbh->{connectionHandle};
 }

 my $db = Vinq::RDB::MySQL->new(driver => 'mysql', dbh => $_dbh);
 return $db;
   }

   1;

and then Vinq::RDBO::User (et al) isa Vinq::RDBO::_mysql.  so far so  
good!


On Feb 8, 2007, at 4:41 PM, Jonathan Vanasco wrote:

>
> On Feb 8, 2007, at 7:24 PM, Michael Reece wrote:
>
>> trying every which way to make Rose::DB::Object(s) always use my
>> custom global $dbh,
>>
>
> i have no idea why your package isn't working (i have a few ideas,
> but no time to test)
>
> i suggest trying this approach, which is essentially what i do:
>
> package Vinq::RDB::Object;
> use Vinq:: Globals ();
> use Vinq::RDB::MySQL ();
> use Rose::DB::Object ();
> use base qw(Rose::DB::Object);
>
> sub init_db {
>   my $db= Vinq::RDB::MySQL->new();
>   $db->dbh( $Vinq::Globals::dbh );
>   return $db;
> };
>
> Then have objects inherit from Vinq::RDB::Object instead of
> Rose::DB::Object.
>
> My system is different, I keep a 'bad' dbh by default and stuff a
> valid dbh manually after i get a read/write/config dbh from a factory
> class.
>
> // Jonathan Vanasco

---
michael reece :: software engineer :: [EMAIL PROTECTED]



-
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


Re: [RDBO] overloading Rose::DB->dbh

2007-02-08 Thread Jonathan Vanasco

On Feb 8, 2007, at 7:24 PM, Michael Reece wrote:

> trying every which way to make Rose::DB::Object(s) always use my
> custom global $dbh,
>

i have no idea why your package isn't working (i have a few ideas,  
but no time to test)

i suggest trying this approach, which is essentially what i do:

package Vinq::RDB::Object;
use Vinq:: Globals ();
use Vinq::RDB::MySQL ();
use Rose::DB::Object ();
use base qw(Rose::DB::Object);

sub init_db {
my $db= Vinq::RDB::MySQL->new();
$db->dbh( $Vinq::Globals::dbh );
return $db;
};

Then have objects inherit from Vinq::RDB::Object instead of  
Rose::DB::Object.

My system is different, I keep a 'bad' dbh by default and stuff a  
valid dbh manually after i get a read/write/config dbh from a factory  
class.

// Jonathan Vanasco

| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -
| SyndiClick.com
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -
|  FindMeOn.com - The cure for Multiple Web Personality Disorder
|  Web Identity Management and 3D Social Networking
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -
|  RoadSound.com - Tools For Bands, Stuff For Fans
|  Collaborative Online Management And Syndication Tools
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -



-
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


[RDBO] overloading Rose::DB->dbh

2007-02-08 Thread Michael Reece
trying every which way to make Rose::DB::Object(s) always use my  
custom global $dbh,

   package Vinq::RDB::MySQL;
   use base 'Rose::DB';

   use Vinq::Globals qw( $dbh );

   __PACKAGE__->use_private_registry;
   __PACKAGE__->register_db(driver => 'mysql');

   sub dbh { $dbh }
   sub driver { 'mysql' }

   1;


things were working great until i tried to

   $junk->add_stuff({ name => 'stuff 1' });
   $junk->save;


which leads to a '$db->commit or die $db->error;', but commit() says  
(in Rose/DB.pm):


   sub commit
   {
 my($self) = shift;

 return 0  unless(defined $self->{'dbh'} && $self->{'dbh'} 
{'Active'});

 my $dbh = $self->dbh or return undef;
 ...


but while $self->dbh returns my $dbh, $self->{'dbh'} hasn't been set  
so it dies (with no error).


are there any docs/tutorials/testimonials about successfully using  
your own $dbh?


-
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