Hello John,

following the guidance from the upcoming Rose-DB tutorial and the tips you gave on the mailinglist (see wiki) I subclassed Rose-DB and Rose-DB-Object for my project.

But it does not work:

package HA26::DB;

use base 'Rose::DB';
use Rose::DB::Registry;

# private Registry anlegen
__PACKAGE__->registry(Rose::DB::Registry->new);

# Standard-Werte
__PACKAGE__->default_domain('uwe'); ###TODO###
__PACKAGE__->default_type('main');

# Uwe
__PACKAGE__->register_db(domain   => 'uwe',
                         type     => 'main',
                         driver   => 'mysql',
                         database => 'HA24',
                         username => 'uwe',
                         password => 'uwe',
                        );

1;

I left out the other datasources (and strict/warnings etc.) ...

When doing HA26::DB->new the following error occurs:
"No database information found for domain 'uwe' and type 'main' at ..."

The problem is init_db_info(). The object is reblessed to Rose::DB::MySQL (and 'HA26::DB' stored in _origin_class). $InheritableScalar looks first in Rose::DB which returns an empty registry. I'm sure you know what I mean. If not, feel free to ask.

The attached patch solves the problem, but you might want to do it in another way. The patch passes all tests.

I'm not sure why my code (HA26::DB) crashes and your testsuite not. What did I do wrong in my subclassing?


Bye, Uwe
Index: DB.pm
===================================================================
RCS file: /cvsroot/rose/rose/modules/Rose-DB/lib/Rose/DB.pm,v
retrieving revision 1.6
diff -u -r1.6 DB.pm
--- DB.pm	28 Sep 2005 20:49:27 -0000	1.6
+++ DB.pm	3 Oct 2005 11:33:10 -0000
@@ -312,7 +313,7 @@
 {
   my($self) = shift;
 
-  my $class = ref $self;
+  my $class = $self->{_origin_class} || ref $self;
 
   my $domain = $self->domain;
   my $type   = $self->type;

Reply via email to