[Catalyst] fix config right before database connect?
Ryan D Johnson
ryandjohnson at gmail.com
Mon Mar 24 18:54:11 GMT 2008
David Wright <dave-catalyst at dexy.org> writes:
>> I'm running several instances of Catalyst app (for every developer
>> and production) on the same box; I'm thinking of automatically patch
>> database name loaded from config file to allow separate copies of
>> databases to coexist transparently.
>
> We have the same multi-instance set up, and instead of patching have
> two config files per instance. The first contains entries common to
> all, and the second adds in instance specific database connect info.
But since the config file can't be dynamic, it's a little
annoying. Another easy option would be to use
Catalyst::Plugin::ConfigLoader::Environment and have people stick
something like this in .bashrc:
export MYAPP_Model__AppDB_connect_info}='["dsn:foo","peanut","butter"]'
Or have a convention and stick this in /etc/bashrc
export MYAPP_Model__AppDB_connect_info="['dsn:mysql:test_$USER','root','']"
But if you really want to do it dynamically in code, its probably most
easily done in your Model class; just override new and set the
connect_info to whatever you like.
More information about the Catalyst
mailing list