On Feb 26, 2007, at 10:58 AM, John Siracusa wrote:

> Yep, that's the way to do it:
>
>     package My::DB::Object; # common base class
>     use base 'Rose::DB::Object';
>     use My::DB;
>
>     our $DB;
>
>     sub init_db { $DB ||= My::DB->new(...) }


Actually, I think you'd be better off with something more like a   
factory pattern.

Have a namespace/module where you create + fetch + lock/unlock db  
availability, and then set the init_db to pull from there.

This way you can manage the transactions outside of rose , and have  
the dbh available easily to all your code.

package MyDbNamespace;
my $dbh;
sub new {};
sub get_dbh {};


>     package My::DB::Object; # common base class
>     use base 'Rose::DB::Object';
>     use My::DB;
sub init_db {
        my $db= My::DB->new();
                $db->dbh( MyDbNamespace::get_db() or die 'DB unavailable' );
        return $db;
}








// 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
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to