[Dbix-class] Problem using DBIC in a Catalyst/mod_perl environment with multiple virtual hosts

Brandon Black blblack at gmail.com
Thu Aug 24 15:40:04 CEST 2006


On 8/24/06, Matt S Trout <dbix-class at trout.me.uk> wrote:
>
> Andreas Dembach wrote:
> > 1) I could not figure out how to get rid of the initial connect_info set
> > by the ->config() call that Cat::DBIC::Schema seems to need during
> > startup, which annoys a little since I do not have any configuration
> > information during Apache startup.
>
> Just don't set it, IIRC


I think the current C:M:DBIC::Schema requires that it be set by the time the
Model's new() method runs.  It doesn't care whether its hardcoded in the
schema_class, or set via $random_config_method, but it does care that its
set at all.  The basic flow of C::M::DBIC::Schema::new()'s schema
manipulation stuff is:

compose_namespace from schema_class to model class, saving return value in
$self->composed_schema
$self->schema($self->composed_schema->connect($connect_info));

I could make it optional and not set up ->schema, but its just one more
place where we're catching errors when people do bad things and fail to
supply a connect_info when they really should have.

In the long-term, once we get DBIx::Class schema-inheritance sufficiently
magical, most of C::M::DBIC::Schema's magic can dissappear, and the model
can just inherit the schema and do a tiny bit of work to set up the
resultset shortcut ACCEPT_CONTEXT/COMPONENT stuff and use ->config.  Then
these sorts of things will be easier (but by then we'll be close to multiple
instances of the same cat app working in mod_perl anyways I suspect).

In the meantime, Andreas, you may want to override new() completely, or just
write your own model base class that handles this for now (since new() is
just about all the code anyways).

-- Brandon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rawmode.org/pipermail/dbix-class/attachments/20060824/8e079aa7/attachment.htm 


More information about the Dbix-class mailing list