FAQ
Hi, folks!

We're using Catalyst::Model::DBIC::Schema (v0.18) for a new web
application, including plugins for authorization and authorization for
DBIC. Everything works fine... until class #20 is added to the
Schema. Then, the application loads succesfully, but then every access
to $c->user builds the sql query using a wrong table!!! We tried
searching around, and there doesn't seem to be more information or
known bug. Plugins loaded:

Catalyst::Plugin::Authentication 0.09
Catalyst::Plugin::Authentication::Credential::Password
Catalyst::Plugin::Authentication::Store::DBIC 0.07
Catalyst::Plugin::Authorization::ACL 0.08
Catalyst::Plugin::Authorization::Roles 0.05
Catalyst::Plugin::Captcha 0.03
Catalyst::Plugin::Config::YAML 0.04
Catalyst::Plugin::ConfigLoader 0.13
Catalyst::Plugin::Email 0.05
Catalyst::Plugin::FillInForm 0.06
Catalyst::Plugin::FormBuilder 1.06
Catalyst::Plugin::FormValidator::Simple 0.10
Catalyst::Plugin::Prototype 1.32
Catalyst::Plugin::Session 0.13
Catalyst::Plugin::Session::State::Cookie 0.06
Catalyst::Plugin::Session::Store::FastMmap 0.02
Catalyst::Plugin::StackTrace 0.06
Catalyst::Plugin::Static::Simple 0.14
Catalyst::Plugin::SubRequest 0.10

We're using PostgreSQL 7.4 server and Catalyst on Debian Etch
(2.6.17-2-686 #1 SMP). The scenario is the same on Catalyst embedded
server and Apache2/mod_perl2 (mpm-prefork).

We're not using DBIx::Class::Schema::Loader, but defining the schema
classes ourselves, like:

package Confianza::Schema::BD;

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

__PACKAGE__->load_classes(qw/

InstFinanciera
PerNat
RolesFunciones
RolesUsuarios
SolicitanteNatural
Solicitante
TpActiviEcon
TpDependLaboral
TpEdoCivil
TpEdoUsuario
TpEmpresa
TpFiguraJur
TpFuncion
TpInstFinanciera
TpPais
TpPersona
TpRol
TpUnidadAdm
TpUsuario
UsuarioInterno
Usuario

/);

First, we were using just load_classes(qw//), with same results. When
removing any 2 classes from the schema (so that less than 20 classes
will remain), the app works fine.

A PAR file with the application and database script can be downloaded here:

http://juanmiguel.no-ip.com/descargas/

Any help will be greatly appreciated!

Search Discussions

  • Juan Miguel Paredes at Dec 14, 2006 at 2:41 pm
    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! :)
  • Brian Cassidy at Dec 14, 2006 at 3:00 pm

    Juan Miguel Paredes wrote:
    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',
    };
    Try only specifying the bits after Model::

    user_class => 'BD::Usuario',

    -Brian
  • Juan Miguel Paredes at Dec 14, 2006 at 3:24 pm

    On 12/14/06, Brian Cassidy wrote:
    Juan Miguel Paredes wrote:
    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',
    };
    Try only specifying the bits after Model::

    user_class => 'BD::Usuario',

    -Brian
    Indeed, it worked fine! Thank you all very, very, much!
  • Brandon Black at Dec 14, 2006 at 4:24 pm

    On 12/14/06, Juan Miguel Paredes wrote:
    On 12/14/06, Brian Cassidy wrote:
    Juan Miguel Paredes wrote:
    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',
    };
    Try only specifying the bits after Model::

    user_class => 'BD::Usuario',

    -Brian
    Indeed, it worked fine! Thank you all very, very, much!
    I suspect this has to do with $c->comp('Foo') magic, which we've had
    issues with in the past with regard to the order in which it resolves
    short and long names, and the eventual regex searching that it does.
    Perhaps that needs revisiting, and/or a stern doc warning not to use
    long names in C::P::Auth::Store::DBIC.

    -- Brandon

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedDec 13, '06 at 6:42p
activeDec 14, '06 at 4:24p
posts5
users3
websitecatalystframework.org
irc#catalyst

People

Translate

site design / logo © 2021 Grokbase