[Dbix-class] Problem using DBIC in a Catalyst/mod_perl environment with multiple virtual hosts
Andreas Dembach
ad at dg-i.net
Tue Aug 22 13:04:04 CEST 2006
Hello list,
we have the following situation:
- we are migrating mod_perl application to Catalyst under mod_perl2 and
use DBIC as persistence layer.
- the apache server hosts two (in fact even more) virtual hosts with the
same application but different configurations (e.g. one for test and one
for production).
- beneath other configuration items, like template-root we want the
different virtual hosts to use different database connections.
Problem:
As far as I can tell from the source code, DBIx::Class::Storage::DBI
caches the database handle in '_dbh' which results in always using the
first database handle that inititated a connection. So we end up having
the configured $dbh of whatever virtual host is called first within a
newly created Apache process.
Question:
Is this a design decision to support only one DB connection per process
or is this a little bug that could be fixed by caching the dbh with some
additional meta info (e.g. the connection parameters à la
DBI->connect_cached)?
We fixed the problem for us by sub-classing
DBIx::Class::Storage::DBI::Pg and overloading the _dbh accessor, but I'd
rather fix this in the storage class.
Best Regards,
Andreas
--
-----------------------------------------------------------------
Dembach Goo Informatik GmbH & Co. KG
Andreas Dembach fon +49-221-801 483 0
Rathenauplatz 9 fax +49-221-801 483 20
D-50674 Cologne emergency +49-180-50 50 70 919
Germany smtp ad +at+ dg-i +dot+ net
pgp fingerprint 25C2 8C94 015A E92C 3C67 E9B7 2E39 6FFC 277D 6700
More information about the Dbix-class
mailing list