[Catalyst] Re: Strange (error)? when trying to load 20 classes or more on DBIx::Class::Schema

Juan Miguel Paredes juan.paredes at gmail.com
Thu Dec 14 14:41:34 GMT 2006


Hi, folks!

We've narrowed the problem: when there are sufficient classes loaded
in the DBIC Schema, the Authentication configuration turns out wrong:

#Confianza.pm (Main Module)
__PACKAGE__->config->{authentication}{dbic} = {
      user_class          => 'Confianza::Model::BD::Usuario',
      user_field          => 'scorreo',
      password_field      => 'scontrasena',
      password_type       => 'hashed',
      password_hash_type  => 'MD5',
  };

meanwhile in the DebugScreen (Config section):

authentication     => {
                            dbic => {
                                  catalyst_user_class =>
"Catalyst::Plugin::Authentication::Store::DBIC::User",
                                  password_field      => "scontrasena",
                                  password_hash_type  => "MD5",
                                  password_type       => "hashed",
                                  user_class          => bless({
                                                           attrs => {
alias => "me" },
                                                           cond => undef,
                                                           count => undef,
                                                           pager => undef,

result_class => "Confianza::Model::BD::UsuarioInterno",
....

This seems to be a name conflict, but, as stated before, it only shows
when there are many classes in the DBIC Schema.  Also, when not
loading 'UsuarioInterno', the app works fine, even with more extra
classes in the schema.

Now, we have actually a user hierarchy from an OO point of view, but
it's implemented in the relational model with parent and children
sharing primary keys, a *might_have* relationship from parent to each
child, and a *has_one* relationship from child to parent (Is there a
better approach?)

Here's the definition of the schema classes involved...

### Parent ###
package Confianza::Schema::BD::Usuario;

use strict;
use base qw/DBIx::Class/;

__PACKAGE__->load_components(qw/InflateColumn::DateTime
ResultSetManager PK::Auto Core/);

__PACKAGE__->table('usuarios');
__PACKAGE__->add_columns(qw/ id id_tpusuario sapellidos snombres
scorreo scontrasena
                             spregreiniciocontrasena
srespreiniciocontrasena id_tpedousuario /);
__PACKAGE__->add_columns( tcreacion => { data_type => 'timestamp' } );

__PACKAGE__->set_primary_key('id');

__PACKAGE__->add_unique_constraint(
    uk_scorreo_usuarios => [ qw/scorreo/ ],
  );

#Lookup tables
__PACKAGE__->belongs_to(id_tpusuario => 'Confianza::Schema::BD::TpUsuario');

__PACKAGE__->belongs_to(id_tpedousuario =>
'Confianza::Schema::BD::TpEdoUsuario');

__PACKAGE__->has_many(map_usuario_rol =>
'Confianza::Schema::BD::RolesUsuarios' => 'id_usuarios' );
__PACKAGE__->many_to_many(roles => 'map_usuario_rol' , 'tprol' );

# *hierarchy* relationships to children
__PACKAGE__->might_have(usuariointerno =>
'Confianza::Schema::BD::UsuarioInterno' => 'id_usuarios' );

__PACKAGE__->might_have(instfinanciera =>
'Confianza::Schema::BD::InstFinanciera' => 'id_usuarios' );

__PACKAGE__->might_have(solicitante =>
'Confianza::Schema::BD::Solicitante' => 'id_usuarios' );


### Child ###
package Confianza::Schema::BD::UsuarioInterno;

use strict;
use base qw/DBIx::Class/;

__PACKAGE__->load_components(qw/PK::Auto Core/);
__PACKAGE__->table('usuariosinternos');
__PACKAGE__->add_columns(qw/ id_usuarios id_tpunidadadm/);
__PACKAGE__->set_primary_key('id_usuarios');

__PACKAGE__->has_one(usuario => 'Confianza::Schema::BD::Usuario',
{'foreign.id' => 'self.id_usuarios'}, {cascade_delete => 0} );

__PACKAGE__->belongs_to(id_tpunidadadm => 'Confianza::Schema::BD::TpUnidadAdm');


We've been scratching our heads for a while, since this approach
actually has been working before... Perhaps we're missing something
important... Thanks again for the kind help! :)



More information about the Catalyst mailing list